Benchmark function call overhead in tight loops
(num_tests)
| 29 | |
| 30 | # ---------------------- Function Call Performance ---------------------- |
| 31 | def test_sequential_fcall(num_tests): |
| 32 | """Benchmark function call overhead in tight loops""" |
| 33 | total_ops = 0 |
| 34 | |
| 35 | def increment(counter): |
| 36 | return counter + 1 |
| 37 | |
| 38 | for _ in range(num_tests): |
| 39 | counter = 0 |
| 40 | start_time = runtime_time() |
| 41 | while runtime_time() - start_time < 1000: |
| 42 | counter = increment(counter) |
| 43 | total_ops += counter |
| 44 | return int(total_ops / num_tests) |
| 45 | |
| 46 | |
| 47 | # ---------------------- Recursion Performance ---------------------- |
no test coverage detected