MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / run_benchmarks

Function run_benchmarks

benchmarks/python-performance.py:89–299  ·  view source on GitHub ↗

Run all benchmarks and display results

()

Source from the content-addressed store, hash-verified

87
88# Benchmark suite
89def run_benchmarks():
90 """Run all benchmarks and display results"""
91 verbose = is_verbose()
92 if verbose:
93 print("=" * 80)
94 print("Python/NumPy Performance Benchmarks")
95 print("=" * 80)
96 print()
97 else:
98 print("Python/NumPy Performance Benchmarks (summary)")
99
100 results = []
101
102 # Simple Power
103 if verbose:
104 print(f"Running: Simple Power (10,000 iterations)")
105 test_data_simple_power = {"x":3,"y":4,"z":5}
106 time_simple_power = benchmark(simple_power, 10000, **test_data_simple_power)
107 result_simple_power = simple_power(**test_data_simple_power)
108 if verbose:
109 print(f" Time: {time_simple_power:.2f} ms")
110 print(f" Result: {result_simple_power}")
111 results.append({
112 'name': 'Simple Power',
113 'iterations': 10000,
114 'time_ms': time_simple_power,
115 'time_per_op_us': (time_simple_power * 1000) / 10000,
116 'result': result_simple_power
117 })
118 if verbose:
119 print()
120
121 # Polynomial
122 if verbose:
123 print(f"Running: Polynomial (10,000 iterations)")
124 test_data_polynomial = {"x":2.5}
125 time_polynomial = benchmark(polynomial, 10000, **test_data_polynomial)
126 result_polynomial = polynomial(**test_data_polynomial)
127 if verbose:
128 print(f" Time: {time_polynomial:.2f} ms")
129 print(f" Result: {result_polynomial}")
130 results.append({
131 'name': 'Polynomial',
132 'iterations': 10000,
133 'time_ms': time_polynomial,
134 'time_per_op_us': (time_polynomial * 1000) / 10000,
135 'result': result_polynomial
136 })
137 if verbose:
138 print()
139
140 # Trigonometric
141 if verbose:
142 print(f"Running: Trigonometric (10,000 iterations)")
143 test_data_trigonometric = {"x":1,"y":2,"z":3}
144 time_trigonometric = benchmark(trigonometric, 10000, **test_data_trigonometric)
145 result_trigonometric = trigonometric(**test_data_trigonometric)
146 if verbose:

Callers 1

Calls 12

is_verboseFunction · 0.85
simple_powerFunction · 0.85
polynomialFunction · 0.85
trigonometricFunction · 0.85
nested_expressionFunction · 0.85
many_variables__20_vars_Function · 0.85
distance_formulaFunction · 0.85
quadratic_formulaFunction · 0.85
kinematicsFunction · 0.85
benchmarkFunction · 0.70
printFunction · 0.50

Tested by

no test coverage detected