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

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

/**
 * Copyright 2011-2016 GatlingCorp (http://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.stats.GeneralStats
import io.gatling.commons.util.NumberHelper._
import io.gatling.commons.util.StringHelper.EmptyFastring
import io.gatling.core.config.GatlingConfiguration

import com.dongxiguo.fastring.Fastring.Implicits._

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

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

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

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

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

  def html = fast"""
                        
STATISTICS

Executions

TotalOKKO
Mean req/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 = EmptyFastring val jsFiles: Seq[String] = Seq.empty }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy