Skip to content

Commit 82cfb96

Browse files
committed
Fix issue with tallying concurrency
Signed-off-by: Samuel Monson <[email protected]>
1 parent 1261fe8 commit 82cfb96

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/guidellm/objects/statistics.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def from_values(
219219
)
220220

221221
@staticmethod
222-
def from_request_times(
222+
def from_request_times( # noqa: C901
223223
requests: list[tuple[float, float]],
224224
distribution_type: Literal["concurrency", "rate"],
225225
include_cdf: bool = False,
@@ -248,13 +248,7 @@ def from_request_times(
248248
time_deltas[start] += 1
249249
time_deltas[end] -= 1
250250

251-
# convert to the events over time measuring concurrency changes
252-
events = []
253-
active = 0
254-
255-
for time, delta in sorted(time_deltas.items()):
256-
active += delta
257-
events.append((time, active))
251+
events = list(time_deltas.items())
258252
elif distribution_type == "rate":
259253
# convert to events for when requests finished
260254
global_start = min(start for start, _ in requests) if requests else 0
@@ -281,6 +275,16 @@ def from_request_times(
281275
else:
282276
flattened_events.append((time, val))
283277

278+
if distribution_type == "concurrency":
279+
# convert to the events over time measuring concurrency changes
280+
events_over_time: list[tuple[float, float]] = []
281+
active = 0
282+
for time, delta in flattened_events:
283+
active += delta # type: ignore [assignment]
284+
events_over_time.append((time, active))
285+
286+
flattened_events = events_over_time
287+
284288
# convert to value distribution function
285289
distribution: dict[float, float] = defaultdict(float)
286290

0 commit comments

Comments
 (0)