All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.gatling.charts.component.StatisticsTextComponent.scala Maven / Gradle / Ivy

There is a newer version: 3.13.1
Show newest version
/*
 * Copyright 2011-2021 GatlingCorp (https://gatling.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.gatling.charts.component

import io.gatling.commons.shared.unstable.model.stats.GeneralStats
import io.gatling.commons.util.NumberHelper._
import io.gatling.core.config.GatlingConfiguration

private[charts] object Statistics {

  def printable[T: Numeric](value: T): String =
    value match {
      case GeneralStats.NoPlotMagicValue => "-"
      case _: Int | _: Long              => value.toString
      case _                             => implicitly[Numeric[T]].toDouble(value).toPrintableString
    }
}

private[charts] final class Statistics[T: Numeric](val name: String, val total: T, val success: T, val failure: T) {
  def all: List[T] = List(total, success, failure)
}

private[charts] final case class GroupedCount(name: String, count: Long, total: Long) {
  val percentage: Int = if (total == 0) 0 else (count.toDouble / total * 100).round.toInt
}

private[charts] final class RequestStatistics(
    val name: String,
    val path: String,
    val numberOfRequestsStatistics: Statistics[Long],
    val minResponseTimeStatistics: Statistics[Int],
    val maxResponseTimeStatistics: Statistics[Int],
    val meanStatistics: Statistics[Int],
    val stdDeviationStatistics: Statistics[Int],
    val percentiles1: Statistics[Int],
    val percentiles2: Statistics[Int],
    val percentiles3: Statistics[Int],
    val percentiles4: Statistics[Int],
    val groupedCounts: Seq[GroupedCount],
    val meanNumberOfRequestsPerSecondStatistics: Statistics[Double]
)

private[charts] class StatisticsTextComponent(implicit configuration: GatlingConfiguration) extends Component {

  override def html: String = s"""
                        
STATISTICS

Executions

TotalOKKO
Mean cnt/s

Response Time (ms)

Total OK KO
Min
${configuration.charting.indicators.percentile1.toRank} percentile
${configuration.charting.indicators.percentile2.toRank} percentile
${configuration.charting.indicators.percentile3.toRank} percentile
${configuration.charting.indicators.percentile4.toRank} percentile
Max
Mean
Std Deviation
""" val js = "" val jsFiles: Seq[String] = Seq.empty }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy