[pypy-commit] pypy expose-gc-time: expose GC time to applevel
cfbolz
pypy.commits at gmail.com
Thu Nov 22 11:35:41 EST 2018
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: expose-gc-time
Changeset: r95357:526c66940c43
Date: 2018-11-22 17:35 +0100
http://bitbucket.org/pypy/pypy/changeset/526c66940c43/
Log: expose GC time to applevel
diff --git a/pypy/module/gc/app_referents.py b/pypy/module/gc/app_referents.py
--- a/pypy/module/gc/app_referents.py
+++ b/pypy/module/gc/app_referents.py
@@ -57,12 +57,14 @@
'total_allocated_memory', 'jit_backend_allocated',
'peak_memory', 'peak_allocated_memory', 'total_arena_memory',
'total_rawmalloced_memory', 'nursery_size',
- 'peak_arena_memory', 'peak_rawmalloced_memory'):
+ 'peak_arena_memory', 'peak_rawmalloced_memory',
+ ):
setattr(self, item, self._format(getattr(self._s, item)))
self.memory_used_sum = self._format(self._s.total_gc_memory + self._s.total_memory_pressure +
self._s.jit_backend_used)
self.memory_allocated_sum = self._format(self._s.total_allocated_memory + self._s.total_memory_pressure +
self._s.jit_backend_allocated)
+ self.total_gc_time = self._s.total_gc_time
def _format(self, v):
if v < 1000000:
@@ -92,6 +94,8 @@
raw assembler allocated: %s%s
-----------------------------
Total: %s
+
+ Total time spent in GC: %s
""" % (self.total_gc_memory, self.peak_memory,
self.total_arena_memory,
self.total_rawmalloced_memory,
@@ -106,7 +110,8 @@
self.nursery_size,
self.jit_backend_allocated,
extra,
- self.memory_allocated_sum)
+ self.memory_allocated_sum,
+ self.total_gc_time / 1000.0)
def get_stats(memory_pressure=False):
diff --git a/pypy/module/gc/referents.py b/pypy/module/gc/referents.py
--- a/pypy/module/gc/referents.py
+++ b/pypy/module/gc/referents.py
@@ -189,6 +189,7 @@
self.peak_arena_memory = rgc.get_stats(rgc.PEAK_ARENA_MEMORY)
self.peak_rawmalloced_memory = rgc.get_stats(rgc.PEAK_RAWMALLOCED_MEMORY)
self.nursery_size = rgc.get_stats(rgc.NURSERY_SIZE)
+ self.total_gc_time = rgc.get_stats(rgc.TOTAL_GC_TIME)
W_GcStats.typedef = TypeDef("GcStats",
total_memory_pressure=interp_attrproperty("total_memory_pressure",
@@ -215,6 +216,8 @@
cls=W_GcStats, wrapfn="newint"),
nursery_size=interp_attrproperty("nursery_size",
cls=W_GcStats, wrapfn="newint"),
+ total_gc_time=interp_attrproperty("total_gc_time",
+ cls=W_GcStats, wrapfn="newint"),
)
@unwrap_spec(memory_pressure=bool)
More information about the pypy-commit
mailing list