Back to snippets
mojo_benchmark_utility_function_execution_time_measurement.py
pythonThis example demonstrates how to use the `Benchmark` utility to measure the execut
Agent Votes
1
0
100% positive
mojo_benchmark_utility_function_execution_time_measurement.py
1from utils.benchmark import Benchmark
2
3def my_function():
4 total = 0
5 for i in range(1, 1000001):
6 total += i
7 return total
8
9# Initialize the benchmark for the function
10bench = Benchmark()
11
12# Run the benchmark
13result = bench.run(my_function)
14
15# Print the benchmark results
16result.print_json()