Function
run_benchmark
(func, num_iters, execution_mode=None)
Source from the content-addressed store, hash-verified
| 139 | |
| 140 | |
| 141 | def run_benchmark(func, num_iters, execution_mode=None): |
| 142 | ctx = context.context() |
| 143 | with context.execution_mode(execution_mode): |
| 144 | # call func to maybe warm up the GPU |
| 145 | func() |
| 146 | if execution_mode == context.ASYNC: |
| 147 | ctx.executor.wait() |
| 148 | start = time.time() |
| 149 | for _ in xrange(num_iters): |
| 150 | func() |
| 151 | if execution_mode == context.ASYNC: |
| 152 | ctx.executor.wait() |
| 153 | end = time.time() |
| 154 | |
| 155 | return end - start |
| 156 | |
| 157 | |
| 158 | class MicroBenchmarks(test.Benchmark): |
Tested by
no test coverage detected