MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / bench

Method bench

test/test_benchmark.py:85–101  ·  view source on GitHub ↗
(self, args, reps=EMTEST_REPS, output_parser=None, expected_output=None)

Source from the content-addressed store, hash-verified

83 pass
84
85 def bench(self, args, reps=EMTEST_REPS, output_parser=None, expected_output=None):
86 self.times = []
87 for _ in range(reps):
88 start = time.time()
89 output = self.run(args)
90 if expected_output is not None and expected_output not in output:
91 raise ValueError('Incorrect benchmark output:\n' + output)
92
93 if not output_parser or args == ['0']: # if arg is 0, we are not running code, and have no output to parse
94 curr = time.time() - start
95 else:
96 try:
97 curr = output_parser(output)
98 except Exception as e:
99 print(str(e))
100 print('Parsing benchmark results failed, output was: ' + output)
101 self.times.append(curr)
102
103 def display(self, baseline=None):
104 # speed

Callers 2

do_benchmarkMethod · 0.80

Calls 4

runMethod · 0.95
appendMethod · 0.80
rangeFunction · 0.50
printFunction · 0.50

Tested by

no test coverage detected