mirror of
https://github.com/python/cpython.git
synced 2025-11-13 15:40:05 +00:00
Simplify code in an example
This commit is contained in:
parent
23bb6f48ea
commit
8ab1258b58
1 changed files with 6 additions and 6 deletions
|
|
@ -429,12 +429,12 @@ Simulation of arrival times and service deliveries in a single server queue::
|
||||||
|
|
||||||
num_waiting = 0
|
num_waiting = 0
|
||||||
arrival = service_end = 0.0
|
arrival = service_end = 0.0
|
||||||
for i in range(10000):
|
for i in range(20000):
|
||||||
|
if arrival <= service_end:
|
||||||
num_waiting += 1
|
num_waiting += 1
|
||||||
arrival += expovariate(1.0 / average_arrival_interval)
|
arrival += expovariate(1.0 / average_arrival_interval)
|
||||||
print(f'{arrival:6.1f} arrived')
|
print(f'{arrival:6.1f} arrived')
|
||||||
|
else:
|
||||||
while arrival > service_end:
|
|
||||||
num_waiting -= 1
|
num_waiting -= 1
|
||||||
service_start = service_end if num_waiting else arrival
|
service_start = service_end if num_waiting else arrival
|
||||||
service_time = gauss(average_service_time, stdev_service_time)
|
service_time = gauss(average_service_time, stdev_service_time)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue