mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Debug WIP: Added option for specifying cycles to run when measuring time
This commit is contained in:
parent
74784f98af
commit
a982368974
1 changed files with 19 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
|||
from itertools import cycle
|
||||
import os, sys, time
|
||||
try:
|
||||
import numpy as np
|
||||
|
@ -8,22 +9,34 @@ except ModuleNotFoundError:
|
|||
|
||||
duration_list = []
|
||||
|
||||
for i in range(1,10):
|
||||
DEFAULT_CYCLES_TO_RUN = 100
|
||||
cycles_to_run = DEFAULT_CYCLES_TO_RUN
|
||||
|
||||
try:
|
||||
cycles_to_run = sys.argv[3] if(sys.argv[3]) else DEFAULT_CYCLES_TO_RUN
|
||||
cycles_to_run = int(cycles_to_run)
|
||||
except IndexError:
|
||||
pass
|
||||
except (ValueError, TypeError):
|
||||
cycles_to_run = DEFAULT_CYCLES_TO_RUN
|
||||
print("Error: Cycles to run argument must be an integer. Using default value of {}".format(DEFAULT_CYCLES_TO_RUN))
|
||||
|
||||
# Numpy complains if we provide a cycle count of less than 3 ~ default to 3 whenever a lower value is provided
|
||||
cycles_to_run = cycles_to_run if cycles_to_run > 2 else 3
|
||||
|
||||
for i in range(1,cycles_to_run):
|
||||
start = time.perf_counter()
|
||||
|
||||
|
||||
# Run the code you want to measure here
|
||||
os.system(sys.argv[1])
|
||||
|
||||
end = time.perf_counter()
|
||||
|
||||
duration_ms = (end - start) * 1000
|
||||
print("SUCCESS: {} : {:.2f}ms +/- {:.2f}% on luau ".format('duration', duration_ms,0))
|
||||
duration_list.append(duration_ms)
|
||||
|
||||
|
||||
# Stats
|
||||
mean = np.mean(duration_list)
|
||||
std_err = stats.sem(duration_list)
|
||||
|
||||
print("--------------------------------------------------------------------------------")
|
||||
print("SUCCESS: {} : {:.2f}ms +/- {:.2f}% on luau ".format('duration', mean,std_err))
|
||||
|
|
Loading…
Add table
Reference in a new issue