MCPcopy Create free account
hub / github.com/apache/arrow / JavaMicrobenchmarkHarnessObservation

Class JavaMicrobenchmarkHarnessObservation

dev/archery/archery/benchmark/jmh.py:90–155  ·  view source on GitHub ↗

Represents one run of a single Java Microbenchmark Harness

Source from the content-addressed store, hash-verified

88
89
90class JavaMicrobenchmarkHarnessObservation:
91 """ Represents one run of a single Java Microbenchmark Harness
92 """
93
94 def __init__(self, benchmark, primaryMetric,
95 forks, warmupIterations, measurementIterations, **counters):
96 self.name = benchmark
97 self.primaryMetric = primaryMetric
98 self.score = primaryMetric["score"]
99 self.score_unit = primaryMetric["scoreUnit"]
100 self.forks = forks
101 self.warmups = warmupIterations
102 self.runs = measurementIterations
103 self.counters = {
104 "mode": counters["mode"],
105 "threads": counters["threads"],
106 "warmups": warmupIterations,
107 "warmupTime": counters["warmupTime"],
108 "measurements": measurementIterations,
109 "measurementTime": counters["measurementTime"],
110 "jvmArgs": counters["jvmArgs"]
111 }
112 self.reciprocal_value = True if self.score_unit.endswith(
113 "/op") else False
114 if self.score_unit.startswith("ops/"):
115 idx = self.score_unit.find("/")
116 self.normalizePerSec(self.score_unit[idx+1:])
117 elif self.score_unit.endswith("/op"):
118 idx = self.score_unit.find("/")
119 self.normalizePerSec(self.score_unit[:idx])
120 else:
121 self.normalizeFactor = 1
122
123 @property
124 def value(self):
125 """ Return the benchmark value."""
126 val = 1 / self.score if self.reciprocal_value else self.score
127 return val * self.normalizeFactor
128
129 def normalizePerSec(self, unit):
130 if unit == "ns":
131 self.normalizeFactor = 1000 * 1000 * 1000
132 elif unit == "us":
133 self.normalizeFactor = 1000 * 1000
134 elif unit == "ms":
135 self.normalizeFactor = 1000
136 elif unit == "min":
137 self.normalizeFactor = 1 / 60
138 elif unit == "hr":
139 self.normalizeFactor = 1 / (60 * 60)
140 elif unit == "day":
141 self.normalizeFactor = 1 / (60 * 60 * 24)
142 else:
143 self.normalizeFactor = 1
144
145 @property
146 def unit(self):
147 if self.score_unit.startswith("ops/"):

Callers 1

from_jsonMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected