Skip to content

Commit

Permalink
Fix performance/stress test script
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknyquist committed Sep 27, 2022
1 parent 0106715 commit b800b82
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/performance_tests/big_class_performance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import matplotlib
import matplotlib.pyplot as plt

from versionedobj import Serializer


sys.path.insert(0, os.path.dirname(__file__))


Expand Down Expand Up @@ -53,6 +56,7 @@ def run_test_iterations(index, nesting_levels, vars_per_level, num_iterations=5)
big_test_class = importlib.import_module(f"{classname}")

init_start = time.time()
ser = Serializer()
cfg = big_test_class.BigTestConfig()
init_time = time.time() - init_start

Expand All @@ -65,19 +69,19 @@ def run_test_iterations(index, nesting_levels, vars_per_level, num_iterations=5)
print(f"Generating data point #{index}")
for i in range(num_iterations):
to_dict_start = time.time()
d = cfg.to_dict()
d = ser.to_dict(cfg)
to_dict_times.append(int((time.time() - to_dict_start) * 1000))

to_json_start = time.time()
j = cfg.to_json()
j = ser.to_json(cfg)
to_json_times.append(int((time.time() - to_json_start) * 1000))

from_dict_start = time.time()
cfg.from_dict(d, validate=False)
ser.from_dict(cfg, d, validate=False)
from_dict_times.append(int((time.time() - from_dict_start) * 1000))

from_json_start = time.time()
cfg.from_json(j, validate=False)
ser.from_json(cfg, j, validate=False)
from_json_times.append(int((time.time() - from_json_start) * 1000))

print(f"completed iteration {i + 1}/{num_iterations}")
Expand Down

0 comments on commit b800b82

Please sign in to comment.