Skip to content

Commit

Permalink
Merge pull request #530 from NVIDIA/fix/state-serialization-test
Browse files Browse the repository at this point in the history
Improve the test serialization test to make it independent of the fir…
  • Loading branch information
drazvan authored Jun 4, 2024
2 parents 045907f + ddec49e commit 2ecae08
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions tests/v2_x/test_state_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,23 @@ async def test_serialization():
assert isinstance(state, State)
assert output_events[0]["script"] == "Hello!"

t0 = time()
s = state_to_json(state)
took = time() - t0

assert took < 0.2
avg_time = 0
number_of_runs = 10
for i in range(0, number_of_runs + 1):
t0 = time()
s = state_to_json(state)
took = time() - t0
if i == 0:
# Skip warm-up run
continue
avg_time += took
avg_time /= number_of_runs

assert avg_time < 0.1

assert isinstance(s, str)

t0 = time()
state_2 = json_to_state(s)
took = time() - t0

assert took < 0.01

assert isinstance(state_2, State)

Expand Down

0 comments on commit 2ecae08

Please sign in to comment.