MCPcopy Index your code
hub / github.com/nodejs/node / Measurements

Class Measurements

deps/v8/tools/avg.py:174–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172
173
174class Measurements:
175
176 def __init__(self):
177 self.all = {}
178 self.default_key = '[default]'
179 self.max_widths = FieldWidth(
180 points=len("{}".format(ARGS['repetitions'])) + 2,
181 key=len("id"),
182 average=len("avg"),
183 stddev=len("stddev"),
184 min_width=len("min"),
185 max_width=len("max"))
186 self.last_status_len = 0
187
188 def record(self, key, value, unit):
189 if not key:
190 key = self.default_key
191 if key not in self.all:
192 self.all[key] = Measurement(key, unit)
193 self.all[key].addValue(value)
194 self.max_widths.max_widths(self.all[key].widths())
195
196 def any(self):
197 if self.all:
198 return next(iter(self.all.values()))
199 return None
200
201 def print_results(self):
202 print("{:<{}}".format("", self.last_status_len), end="\r")
203 print(result_header(self.max_widths), sep=" ")
204 for key in sorted(self.all):
205 print(self.all[key].result(self.max_widths), sep=" ")
206
207 def print_status(self):
208 status = "No results found. Check format?"
209 measurement = MEASUREMENTS.any()
210 if measurement:
211 status = measurement.status(MEASUREMENTS.max_widths)
212 print("{:<{}}".format(status, self.last_status_len), end="\r")
213 self.last_status_len = len(status)
214
215
216MEASUREMENTS = Measurements()

Callers 1

avg.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…