Skip to content

Commit

Permalink
Use time.perf_counter for time measurements
Browse files Browse the repository at this point in the history
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 <rtobar@icrar.org>

counter
  • Loading branch information
rtobar committed Nov 30, 2023
1 parent 6d4bbb1 commit 6a6586d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ijson/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,12 @@ def run(reader):

# Go, go, go!
durations = []
now = time.perf_counter
for iteration in range(args.iterations):
with contextlib.closing(get_reader()) as reader:
start = time.time()
start = now()
run(reader)
durations.append(time.time() - start)
durations.append(now() - start)
megabytes = size / 1024. / 1024.
results = (
(megabytes, args.method, bname, backend_name) +
Expand Down

0 comments on commit 6a6586d

Please sign in to comment.