mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
add a script to benchmark build times
This commit is contained in:
parent
eaf02ef7bd
commit
69da8bdea7
1 changed files with 19 additions and 0 deletions
19
script/bench_build.py
Normal file
19
script/bench_build.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import subprocess
|
||||
|
||||
def run_build(crate):
|
||||
subprocess.run(["touch", f"crates/{crate}/src/{crate}.rs"])
|
||||
result = subprocess.run(["cargo", "build", "--timings"], capture_output=True, text=True)
|
||||
output = result.stderr.splitlines()[-1].split(" ")[-1]
|
||||
return float(output.rstrip('s'))
|
||||
|
||||
def run_bench(crate, n = 5):
|
||||
results = []
|
||||
for i in range(n):
|
||||
results.append(run_build(crate))
|
||||
print(f"Run {i+1}/{n} took {results[-1]} seconds")
|
||||
|
||||
average = sum(results) / len(results)
|
||||
print(f"Average build time: {average:.2f} seconds")
|
||||
return average
|
||||
|
||||
run_bench("project")
|
Loading…
Reference in a new issue