Benchmark.scala 3.1 KB
Newer Older
1
2
3
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
//
4
// This file is part of Tapasco (TPC).
5
//
6
// Tapasco is free software: you can redistribute it and/or modify
7
8
9
10
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
11
// Tapasco is distributed in the hope that it will be useful,
12
13
14
15
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
17
// along with Tapasco.  If not, see <http://www.gnu.org/licenses/>.
18
19
20
21
//
/**
 * @file    Benchmark.scala
 * @brief   Model: TPC IP Benchmark.
Jens Korinth's avatar
Jens Korinth committed
22
 * @todo    Scaladoc is missing.
23
24
 * @authors J. Korinth, TU Darmstadt (jk@esa.cs.tu-darmstadt.de)
 **/
25
package de.tu_darmstadt.cs.esa.tapasco.base
Jens Korinth's avatar
Jens Korinth committed
26
import  de.tu_darmstadt.cs.esa.tapasco.util.LinearInterpolator
27
28
29
30
import  builder._
import  java.time.LocalDateTime
import  java.nio.file._

31
final case class LibraryVersions(platform: String, tapasco: String)
32
33
final case class Host(machine: String, node: String, operatingSystem: String, release: String, version: String)
final case class TransferSpeedMeasurement(chunkSize: Int, read: Double, write: Double, readWrite: Double)
Jens Korinth's avatar
Jens Korinth committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
final case class InterruptLatency(clockCycles: Int, latency: Double)
/** Defines an interpolation on [[InterruptLatency]] elements. */
final class LatencyInterpolator(data: Seq[InterruptLatency])
    extends LinearInterpolator[Int, Double](data map { il => (il.clockCycles, il.latency) }) {
  def interpolate(cc: Int, left: (Int, Double), right: (Int, Double)): Double = {
    val l = left._1.toDouble
    val r = right._1.toDouble
    ((cc.toDouble - l) / (r - l)) * (right._2 - left._2) + left._2
  }
}
/** Defines an interpolation on [[TransferSpeedMeasurements]]. */
final class TransferSpeedInterpolator(data: Seq[TransferSpeedMeasurement])
    extends LinearInterpolator[Int, (Double, Double, Double)](data map { ts: TransferSpeedMeasurement =>
      (ts.chunkSize, (ts.read, ts.write, ts.readWrite))
    }) {
  /** Shorthand type. */
  type Rwrw = (Double, Double, Double)
  def interpolate(cs: Int, left: (Int, Rwrw), right: (Int, Rwrw)): Rwrw = {
    val l = left._1.toDouble
    val r = right._1.toDouble
    val f = (cs.toDouble - l) / (r - l)
    (f * (right._2._1 - left._2._1) + left._2._1,
     f * (right._2._2 - left._2._2) + left._2._2,
     f * (right._2._3 - left._2._3) + left._2._3)
  }
}
60
final case class Benchmark (
Jens Korinth's avatar
Jens Korinth committed
61
62
63
64
65
66
67
68
69
70
71
72
      descPath: Path,
      timestamp: LocalDateTime,
      host: Host,
      libraryVersions: LibraryVersions,
      transferSpeed: Seq[TransferSpeedMeasurement],
      interruptLatency: Seq[InterruptLatency]
    ) extends Description(descPath) {
  /** Function to compute interpolated latency values. */
  lazy val latency = new LatencyInterpolator(interruptLatency)
  /** Function to compute interpolated transfer speed values. */
  lazy val speed   = new TransferSpeedInterpolator(transferSpeed)
}
73
74

object Benchmark extends Builds[Benchmark]