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

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

There is a newer version: 3.13.1
Show newest version
/*
 * Copyright 2011-2024 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 java.time.{ Duration, Instant, ZoneId }
import java.time.format.DateTimeFormatter

import io.gatling.charts.stats.RunInfo
import io.gatling.charts.util.HtmlHelper._
import io.gatling.commons.util.GatlingVersion
import io.gatling.commons.util.StringHelper._

private[charts] final class SimulationCardComponent(runInfo: RunInfo, zoneId: ZoneId) extends Component {

  override def html: String = {
    val printableRunDateTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss O").withZone(zoneId).format(Instant.ofEpochMilli(runInfo.injectStart))
    val printableGatlingReleaseDate = GatlingVersion.ThisVersion.releaseDate.toLocalDate.toString
    val printableDuration = {
      val duration = Duration.ofMillis(runInfo.injectEnd - runInfo.injectStart)
      val days = duration.toDays
      val minusDays = duration.minusDays(days)
      val hours = minusDays.toHours
      val minusHours = minusDays.minusHours(hours)
      val minutes = minusHours.toMinutes
      val seconds = minusHours.minusMinutes(minutes).getSeconds

      (if (days > 0) s"${days}d " else "") +
        (if (hours > 0) s"${hours}h " else if (days > 0) "0h" else "") +
        (if (minutes > 0) s"${minutes}m " else if (days > 0 || hours > 0) "0m" else "") +
        (if (seconds > 0) s"${seconds}s " else "0s")
    }

    s"""
|
| Gatling Version | | Version: | ${GatlingVersion.ThisVersion.fullVersion} | | | Released: | $printableGatlingReleaseDate | |
|
| Run Information |
| | Date: | $printableRunDateTime | | | Duration: | $printableDuration | | ${if (runInfo.runDescription.nonEmpty) { s""" | Description: | ${runInfo.runDescription.truncate(2300).htmlEscape} | |""".stripMargin } else { """ | Description: | | |""".stripMargin }} |
|
|
""".stripMargin } override def js: String = "" override def jsFiles: Seq[String] = Nil }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy