()
| 17 | |
| 18 | # Set up the benchmarking function |
| 19 | def benchmark_docker_execute(): |
| 20 | print("Setting up...") |
| 21 | |
| 22 | docker_execute = DockerExecute(sources_dirname=sources_dirname) |
| 23 | |
| 24 | print("Priming the pump...") |
| 25 | |
| 26 | # Prime the pump |
| 27 | exit_code, output = docker_execute.execute(test_script) |
| 28 | assert output == expected_output, f"Unexpected output: {output}" |
| 29 | assert exit_code == 0, f"Unexpected exit code: {exit_code}" |
| 30 | |
| 31 | print("Benchmarking...") |
| 32 | |
| 33 | try: |
| 34 | # Measure the execution time of the method |
| 35 | exec_time = timeit.timeit( |
| 36 | lambda: docker_execute.execute(test_script), number=4 |
| 37 | ) |
| 38 | finally: |
| 39 | # Clean up the Docker container |
| 40 | docker_execute.shutdown() |
| 41 | |
| 42 | return exec_time |
| 43 | |
| 44 | # Run the benchmark |
| 45 | exec_time = benchmark_docker_execute() |
no test coverage detected