Skip to content

Commit

Permalink
Fix Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom committed Jun 12, 2024
1 parent c0ed773 commit ad789ee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pyperf/_process_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def merge_profile_stats_files(src, dst):


def bench_process(loops, args, kw, profile_filename=None):
if resource is not None:
rusage_children = resource.RUSAGE_CHILDREN
else:
rusage_children = 0

max_rss = 0
range_it = range(loops)
start_time = time.perf_counter()
Expand All @@ -61,7 +66,7 @@ def bench_process(loops, args, kw, profile_filename=None):
args = [args[0], "-m", "cProfile", "-o", temp_profile_filename] + args[1:]

for _ in range_it:
start_rss = get_max_rss(resource.RUSAGE_CHILDREN)
start_rss = get_max_rss(rusage_children)

proc = subprocess.Popen(args, **kw)
with proc:
Expand All @@ -75,7 +80,7 @@ def bench_process(loops, args, kw, profile_filename=None):
os.unlink(temp_profile_filename)
sys.exit(exitcode)

rss = get_max_rss(resource.RUSAGE_CHILDREN) - start_rss
rss = get_max_rss(rusage_children) - start_rss
max_rss = max(max_rss, rss)

if profile_filename:
Expand Down

0 comments on commit ad789ee

Please sign in to comment.