@@ -219,7 +219,7 @@ def from_values(
219
219
)
220
220
221
221
@staticmethod
222
- def from_request_times (
222
+ def from_request_times ( # noqa: C901
223
223
requests : list [tuple [float , float ]],
224
224
distribution_type : Literal ["concurrency" , "rate" ],
225
225
include_cdf : bool = False ,
@@ -248,13 +248,7 @@ def from_request_times(
248
248
time_deltas [start ] += 1
249
249
time_deltas [end ] -= 1
250
250
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 ())
258
252
elif distribution_type == "rate" :
259
253
# convert to events for when requests finished
260
254
global_start = min (start for start , _ in requests ) if requests else 0
@@ -281,6 +275,16 @@ def from_request_times(
281
275
else :
282
276
flattened_events .append ((time , val ))
283
277
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
+
284
288
# convert to value distribution function
285
289
distribution : dict [float , float ] = defaultdict (float )
286
290
0 commit comments