Skip to content

Commit

Permalink
add num_reps to test config (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel authored Jul 22, 2021
1 parent 9908a94 commit 59618be
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Tools/scripts/lazy_marshal_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
_STEADY_STATE = "steady-state"


def speed_comparison(source: str, test_name: str):
def speed_comparison(source: str, test_name: str, reps: int):
print()
print(f"Starting speed test: {test_name}")

def load_helper(data, label, timings, lazy):
codes = []
t0 = time.perf_counter()
for _ in range(1000):
for _ in range(reps):
code = marshal.loads(data, lazy=lazy)
codes.append(code)
t1 = time.perf_counter()
Expand Down Expand Up @@ -90,6 +90,7 @@ def last_exec_time(t):
SpeedTestParams = namedtuple(
"SpeedTestParams",
[
"num_reps",
"num_funcs",
"func_length",
"num_vars",
Expand All @@ -102,6 +103,7 @@ def last_exec_time(t):


def test_name(p: SpeedTestParams):
nreps = p.num_reps
nfuncs = p.num_funcs
nvars = p.num_vars
scope = "locals" if p.is_locals else "globals"
Expand All @@ -110,7 +112,7 @@ def test_name(p: SpeedTestParams):
consts = "consts" if p.is_vary_constants else ""
return (
f"{shared:6} {is_call:4} {scope:7} {consts:6} "
f"{nfuncs:4} funcs, {nvars:4} vars"
f"{nfuncs:4} funcs, {nvars:4} vars, {nreps:4} reps"
)


Expand Down Expand Up @@ -162,6 +164,7 @@ def get_source(self):
def run_tests():
results = {}
for params in itertools.product(
[1000], # num_reps
[100], # num_funcs
[100], # func_length
[10, 100], # num_vars
Expand All @@ -174,7 +177,7 @@ def run_tests():
while gc.collect():
pass
builder = SpeedTestBuilder(p)
results[p] = speed_comparison(builder.get_source(), test_name(p))
results[p] = speed_comparison(builder.get_source(), test_name(p), p.num_reps)
return results


Expand Down

0 comments on commit 59618be

Please sign in to comment.