time.process_time() instead of time.clock()
Documentation removed in b6a09ae287
This commit is contained in:
@@ -127,7 +127,7 @@ class Panama:
|
||||
## positive for words on left, negative for right.
|
||||
## .stack holds (action, side, arg) tuples
|
||||
update(self, left=[], right=[], best=0, seen={}, diff=0, stack=[],
|
||||
used_reversibles=False, starttime=time.clock(), dict=dict)
|
||||
used_reversibles=False, starttime=time.process_time(), dict=dict)
|
||||
for word in L.split(','):
|
||||
self.add('left', canonical(word))
|
||||
for rword in reversestr(R).split(','):
|
||||
@@ -209,7 +209,7 @@ class Panama:
|
||||
self.best = len(self)
|
||||
self.bestphrase = str(self)
|
||||
print('%5d phrases (%5d words) in %3d seconds' % (
|
||||
self.best, self.bestphrase.count(' ')+1, time.clock() - self.starttime))
|
||||
self.best, self.bestphrase.count(' ')+1, time.process_time() - self.starttime))
|
||||
assert is_panama(self.bestphrase)
|
||||
f = open('pallog%d.txt' % (id(self) % 10000), 'w')
|
||||
f.write(self.bestphrase + '\n')
|
||||
|
||||
@@ -79,7 +79,7 @@ def unit_tests():
|
||||
def spelltest(tests, verbose=False):
|
||||
"Run correction(wrong) on all (right, wrong) pairs; report results."
|
||||
import time
|
||||
start = time.clock()
|
||||
start = time.process_time()
|
||||
good, unknown = 0, 0
|
||||
n = len(tests)
|
||||
for right, wrong in tests:
|
||||
@@ -90,7 +90,7 @@ def spelltest(tests, verbose=False):
|
||||
if verbose:
|
||||
print('correction({}) => {} ({}); expected {} ({})'
|
||||
.format(wrong, w, WORDS[w], right, WORDS[right]))
|
||||
dt = time.clock() - start
|
||||
dt = time.process_time() - start
|
||||
print('{:.0%} of {} correct ({:.0%} unknown) at {:.0f} words per second '
|
||||
.format(good / n, n, unknown / n, n / dt))
|
||||
|
||||
|
||||
@@ -138,9 +138,9 @@ def solve_all(grids, name=''):
|
||||
sum(results), N, name, sum(times)/N, N/sum(times), max(times)))
|
||||
|
||||
def time_solve(grid):
|
||||
start = time.clock()
|
||||
start = time.process_time()
|
||||
values = solve(grid)
|
||||
t = time.clock()-start
|
||||
t = time.process_time()-start
|
||||
return (t, solved(values))
|
||||
|
||||
def solved(values):
|
||||
|
||||
Reference in New Issue
Block a user