(self, args, reps=EMTEST_REPS, output_parser=None, expected_output=None)
| 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 |
no test coverage detected