Author: Antonio Cuni <[email protected]>
Branch: gc-disable
Changeset: r94681:a75d8c7f141f
Date: 2018-05-23 14:50 +0200
http://bitbucket.org/pypy/pypy/changeset/a75d8c7f141f/
Log: add an option to control how the gc works inside gcbench: you can
choose whether to use gc.disable() and/or gc.collect(1)
diff --git a/rpython/translator/goal/gcbench.py
b/rpython/translator/goal/gcbench.py
--- a/rpython/translator/goal/gcbench.py
+++ b/rpython/translator/goal/gcbench.py
@@ -44,8 +44,9 @@
# - Results are sensitive to locking cost, but we dont
# check for proper locking
import time
+import gc
-USAGE = """gcbench [num_repetitions] [--depths=N,N,N..] [--threads=N]"""
+USAGE = """gcbench [num_repetitions] [--depths=N,N,N..] [--threads=N]
[--gc=off|--gc=manual]"""
ENABLE_THREADS = True
@@ -173,6 +174,7 @@
depths = DEFAULT_DEPTHS
threads = 0
repeatcount = 1
+ gc_policy = 'on'
for arg in argv[1:]:
if arg.startswith('--threads='):
arg = arg[len('--threads='):]
@@ -189,13 +191,22 @@
depths = [int(s) for s in arg]
except ValueError:
return argerror()
+ elif arg.startswith('--gc=off'):
+ gc_policy = 'off'
+ elif arg.startswith('--gc=manual'):
+ gc_policy = 'manual'
else:
try:
repeatcount = int(arg)
except ValueError:
return argerror()
+ #
+ if gc_policy == 'off' or gc_policy == 'manual':
+ gc.disable()
for i in range(repeatcount):
main(depths, threads)
+ if gc_policy == 'manual':
+ gc.collect(1)
return 0
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit