diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2022-10-20 23:56:43 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2022-10-20 23:56:43 +0200 |
commit | 1b09c1b54cb2ae46145de7f710e9b990cd264016 (patch) | |
tree | 8d07730fce5b1b82996a4c47d8a3a138c86f9756 /scripts | |
parent | 44721d7fc3e02d5afcc4236fc1463f64f4530862 (diff) | |
download | psutil-1b09c1b54cb2ae46145de7f710e9b990cd264016.tar.gz |
fix py2 compatibility
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/internal/print_api_speed.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/scripts/internal/print_api_speed.py b/scripts/internal/print_api_speed.py index f41d0466..e85b7038 100755 --- a/scripts/internal/print_api_speed.py +++ b/scripts/internal/print_api_speed.py @@ -75,6 +75,7 @@ from __future__ import print_function import argparse import inspect import os +import sys from timeit import default_timer as timer import psutil @@ -105,14 +106,16 @@ def print_timings(): def timecall(title, fun, *args, **kw): - print("%-50s" % title, end="", flush=True) + print("%-50s" % title, end="") + sys.stdout.flush() t = timer() for n in range(TIMES): fun(*args, **kw) elapsed = timer() - t if elapsed > 2: break - print("\r", end="", flush=True) + print("\r", end="") + sys.stdout.flush() timings.append((title, n + 1, elapsed)) |