Difficult-Rocket/performance_test/test_for_speed.py

35 lines
665 B
Python
Raw Normal View History

2021-06-26 14:15:33 +08:00
# test of "for" speed
# R5 5600X 16*2GB DDR4 3200
import random
import time
from pprint import pprint
2021-07-08 20:42:22 +08:00
2021-06-26 14:15:33 +08:00
TPS = 60
SPT = 1 / TPS
list_num = 100
test_list = {}
for x in range(list_num):
test_list[x] = [random.random()]
time_list = {}
times = 100
t = 0
start_t = time.time()
while t < times:
s_t = time.time()
t += 1
for x in test_list:
if test_list[x][0] > 0.5:
print('y', end=' ')
else:
print('n', end=' ')
pass
print(t, end='\n')
e_t = time.time()
2021-07-08 20:42:22 +08:00
time_list[t] = [s_t, e_t, e_t - s_t]
2021-06-26 14:15:33 +08:00
end_time = time.time()
pprint(time_list)
pprint(test_list)
2021-07-08 20:42:22 +08:00
print(start_t, end_time, end_time - start_t)