mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-10 21:58:48 +01:00
- Note: process_time gives CPU time used and perf_counter is absolute time used. - Looks to have noise of about 1-2%.
20 lines
346 B
Python
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)) |