-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.py
More file actions
31 lines (26 loc) · 886 Bytes
/
Copy pathbenchmark.py
File metadata and controls
31 lines (26 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import subprocess
import re
import matplotlib.pyplot as plt
import math
results = []
# Sampling every 100th value in the range from 12 to 10 million
from_num = 10
to_num = 100_000
step_num = 2 * math.floor(math.sqrt(to_num - from_num))
for i in range(from_num, to_num, step_num):
command = f"time build/out benchmark {i}"
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process.wait()
output = process.stderr.read().decode().strip()
time_info = re.findall(r"(\d+\.\d+)(m\ds)?", output)
if time_info:
time_value = float(time_info[-1][0])
results.append((i, time_value))
x_values, y_values = zip(*results)
plt.figure(figsize=(8, 6))
plt.scatter(x_values, y_values)
plt.xlabel('Parameter Value')
plt.ylabel('Execution Time (s)')
plt.title('Benchmark Results (Sampled)')
plt.grid(True)
plt.show()