Files
wren/test/benchmark/for.py
Bill Quith 0fa16a20ec Fix deprecated Python timing in benchmark & give more error info. (#844)
- Note: process_time gives CPU time used and perf_counter is absolute time used.
- Looks to have noise of about 1-2%.
2021-01-30 21:40:20 -08:00

20 lines
346 B
Python

from __future__ import print_function
import time
# Map "range" to an efficient range in both Python 2 and 3.
try:
range = xrange
except NameError:
pass
start = time.process_time()
list = []
for i in range(0, 1000000):
list.append(i)
sum = 0
for i in list:
sum += i
print(sum)
print("elapsed: " + str(time.process_time() - start))