Skip to content

Commit 585fee5

Browse files
committed
test_snapshot_ab: open code sample_latency
This function only has one possible call-site, and that's test_restore_latency. Inlining it into its call site makes things a bit simpler (no need for a temporary array). Signed-off-by: Patrick Roy <[email protected]>
1 parent d43e43d commit 585fee5

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

tests/integration_tests/performance/test_snapshot_ab.py

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import tempfile
55
from dataclasses import dataclass
66
from functools import lru_cache
7-
from typing import List
87

98
import pytest
109

@@ -83,25 +82,6 @@ def configure_vm(self, microvm_factory, guest_kernel, rootfs, metrics) -> Microv
8382

8483
return vm
8584

86-
def sample_latency(self, microvm_factory, snapshot) -> List[float]:
87-
"""Collects latency samples for the microvm configuration specified by this instance"""
88-
values = []
89-
90-
for microvm in microvm_factory.build_n_from_snapshot(snapshot, ITERATIONS):
91-
value = 0
92-
# Parse all metric data points in search of load_snapshot time.
93-
microvm.flush_metrics()
94-
metrics = microvm.get_all_metrics()
95-
for data_point in metrics:
96-
cur_value = data_point["latencies_us"]["load_snapshot"]
97-
if cur_value > 0:
98-
value = cur_value / USEC_IN_MSEC
99-
break
100-
assert value > 0
101-
values.append(value)
102-
103-
return values
104-
10585

10686
@pytest.mark.nonci
10787
@pytest.mark.parametrize(
@@ -136,10 +116,14 @@ def test_restore_latency(
136116
snapshot = vm.snapshot_full()
137117
vm.kill()
138118

139-
samples = test_setup.sample_latency(
140-
microvm_factory,
141-
snapshot,
142-
)
143-
144-
for sample in samples:
145-
metrics.put_metric("latency", sample, "Milliseconds")
119+
for microvm in microvm_factory.build_n_from_snapshot(snapshot, ITERATIONS):
120+
value = 0
121+
# Parse all metric data points in search of load_snapshot time.
122+
microvm.flush_metrics()
123+
for data_point in microvm.get_all_metrics():
124+
cur_value = data_point["latencies_us"]["load_snapshot"]
125+
if cur_value > 0:
126+
value = cur_value / USEC_IN_MSEC
127+
break
128+
assert value > 0
129+
metrics.put_metric("latency", value, "Milliseconds")

0 commit comments

Comments
 (0)