Skip to content

Commit 6a6586d

Browse files
committed
Use time.perf_counter for time measurements
This the reliable, multiplatform, recommended way to measure times when doing benchmarks, and it is available unconditionally now that we support Python 3.5+. Signed-off-by: Rodrigo Tobar <[email protected]> counter
1 parent 6d4bbb1 commit 6a6586d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ijson/benchmark.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,12 @@ def run(reader):
201201

202202
# Go, go, go!
203203
durations = []
204+
now = time.perf_counter
204205
for iteration in range(args.iterations):
205206
with contextlib.closing(get_reader()) as reader:
206-
start = time.time()
207+
start = now()
207208
run(reader)
208-
durations.append(time.time() - start)
209+
durations.append(now() - start)
209210
megabytes = size / 1024. / 1024.
210211
results = (
211212
(megabytes, args.method, bname, backend_name) +

0 commit comments

Comments
 (0)