forked from Mirror/wren
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%.
This commit is contained in:
@ -29,7 +29,7 @@ min_depth = 4
|
|||||||
max_depth = 12
|
max_depth = 12
|
||||||
stretch_depth = max_depth + 1
|
stretch_depth = max_depth + 1
|
||||||
|
|
||||||
start = time.clock()
|
start = time.process_time()
|
||||||
print("stretch tree of depth %d check:" % stretch_depth, check_tree(make_tree(0, stretch_depth)))
|
print("stretch tree of depth %d check:" % stretch_depth, check_tree(make_tree(0, stretch_depth)))
|
||||||
|
|
||||||
long_lived_tree = make_tree(0, max_depth)
|
long_lived_tree = make_tree(0, max_depth)
|
||||||
@ -45,4 +45,4 @@ for depth in range(min_depth, stretch_depth, 2):
|
|||||||
iterations //= 4
|
iterations //= 4
|
||||||
|
|
||||||
print("long lived tree of depth %d check:" % max_depth, check_tree(long_lived_tree))
|
print("long lived tree of depth %d check:" % max_depth, check_tree(long_lived_tree))
|
||||||
print("elapsed: " + str(time.clock() - start))
|
print("elapsed: " + str(time.process_time() - start))
|
||||||
@ -625,12 +625,12 @@ planner = None
|
|||||||
|
|
||||||
def delta_blue():
|
def delta_blue():
|
||||||
global total
|
global total
|
||||||
start = time.clock()
|
start = time.process_time()
|
||||||
for i in range(40):
|
for i in range(40):
|
||||||
chain_test(100)
|
chain_test(100)
|
||||||
projection_test(100)
|
projection_test(100)
|
||||||
print(total)
|
print(total)
|
||||||
print("elapsed: " + str(time.clock() - start))
|
print("elapsed: " + str(time.process_time() - start))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@ -6,7 +6,7 @@ def fib(n):
|
|||||||
if n < 2: return n
|
if n < 2: return n
|
||||||
return fib(n - 1) + fib(n - 2)
|
return fib(n - 1) + fib(n - 2)
|
||||||
|
|
||||||
start = time.clock()
|
start = time.process_time()
|
||||||
for i in range(0, 5):
|
for i in range(0, 5):
|
||||||
print(fib(28))
|
print(fib(28))
|
||||||
print("elapsed: " + str(time.clock() - start))
|
print("elapsed: " + str(time.process_time() - start))
|
||||||
@ -8,7 +8,7 @@ try:
|
|||||||
except NameError:
|
except NameError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
start = time.clock()
|
start = time.process_time()
|
||||||
list = []
|
list = []
|
||||||
for i in range(0, 1000000):
|
for i in range(0, 1000000):
|
||||||
list.append(i)
|
list.append(i)
|
||||||
@ -17,4 +17,4 @@ sum = 0
|
|||||||
for i in list:
|
for i in list:
|
||||||
sum += i
|
sum += i
|
||||||
print(sum)
|
print(sum)
|
||||||
print("elapsed: " + str(time.clock() - start))
|
print("elapsed: " + str(time.process_time() - start))
|
||||||
@ -2,7 +2,7 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
start = time.clock()
|
start = time.process_time()
|
||||||
|
|
||||||
map = {}
|
map = {}
|
||||||
|
|
||||||
@ -17,4 +17,4 @@ print(sum)
|
|||||||
for i in range(1, 2000001):
|
for i in range(1, 2000001):
|
||||||
del map[i]
|
del map[i]
|
||||||
|
|
||||||
print("elapsed: " + str(time.clock() - start))
|
print("elapsed: " + str(time.process_time() - start))
|
||||||
@ -78,7 +78,7 @@ for animal in animals:
|
|||||||
for adverb in adverbs:
|
for adverb in adverbs:
|
||||||
keys.append(adverb + " " + adjective + " " + animal)
|
keys.append(adverb + " " + adjective + " " + animal)
|
||||||
|
|
||||||
start = time.clock()
|
start = time.process_time()
|
||||||
|
|
||||||
map = {}
|
map = {}
|
||||||
i = 0
|
i = 0
|
||||||
@ -94,4 +94,4 @@ for key in keys:
|
|||||||
del map[key]
|
del map[key]
|
||||||
|
|
||||||
print(sum)
|
print(sum)
|
||||||
print("elapsed: " + str(time.clock() - start))
|
print("elapsed: " + str(time.process_time() - start))
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class NthToggle(Toggle):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
start = time.clock()
|
start = time.process_time()
|
||||||
|
|
||||||
NUM = 100000
|
NUM = 100000
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print("false")
|
print("false")
|
||||||
|
|
||||||
print("elapsed: " + str(time.clock() - start))
|
print("elapsed: " + str(time.process_time() - start))
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import time
|
import time
|
||||||
start = time.clock()
|
start = time.process_time()
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
for i in range(0, 1000000):
|
for i in range(0, 1000000):
|
||||||
@ -32,4 +32,4 @@ for i in range(0, 1000000):
|
|||||||
count = count + 1
|
count = count + 1
|
||||||
|
|
||||||
print(count)
|
print(count)
|
||||||
print("elapsed: " + str(time.clock() - start))
|
print("elapsed: " + str(time.process_time() - start))
|
||||||
|
|||||||
@ -182,9 +182,9 @@ def run_benchmark_language(benchmark, language, benchmark_result):
|
|||||||
name = "{0} - {1}".format(benchmark[0], language[0])
|
name = "{0} - {1}".format(benchmark[0], language[0])
|
||||||
print("{0:30s}".format(name), end=' ')
|
print("{0:30s}".format(name), end=' ')
|
||||||
|
|
||||||
if not os.path.exists(os.path.join(
|
bpath = os.path.join(BENCHMARK_DIR, benchmark[0] + language[2])
|
||||||
BENCHMARK_DIR, benchmark[0] + language[2])):
|
if not os.path.exists(bpath):
|
||||||
print("No implementation for this language")
|
print("No implementation for this language: " + bpath)
|
||||||
return
|
return
|
||||||
|
|
||||||
times = []
|
times = []
|
||||||
|
|||||||
Reference in New Issue
Block a user