[pypy-commit] pypy gc-hooks: expose rlib.rtimer.read_timestamp as __pypy__.debug_read_timestamp. The underlying idea is that these values are now exposed to applevel by gchooks (in particular, stats.duration), so some 3rd-party library might want to use this to do calibration or to convert the raw values to (milli)seconds

antocuni pypy.commits at gmail.com
Mon Apr 16 05:38:46 EDT 2018


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: gc-hooks
Changeset: r94346:d68302cf28a3
Date: 2018-04-16 11:33 +0200
http://bitbucket.org/pypy/pypy/changeset/d68302cf28a3/

Log:	expose rlib.rtimer.read_timestamp as __pypy__.debug_read_timestamp.
	The underlying idea is that these values are now exposed to applevel
	by gchooks (in particular, stats.duration), so some 3rd-party
	library might want to use this to do calibration or to convert the
	raw values to (milli)seconds

diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -82,6 +82,7 @@
         'debug_stop'                : 'interp_debug.debug_stop',
         'debug_print_once'          : 'interp_debug.debug_print_once',
         'debug_flush'               : 'interp_debug.debug_flush',
+        'debug_read_timestamp'      : 'interp_debug.debug_read_timestamp',
         'builtinify'                : 'interp_magic.builtinify',
         'hidden_applevel'           : 'interp_magic.hidden_applevel',
         'get_hidden_tb'             : 'interp_magic.get_hidden_tb',
diff --git a/pypy/module/__pypy__/interp_debug.py b/pypy/module/__pypy__/interp_debug.py
--- a/pypy/module/__pypy__/interp_debug.py
+++ b/pypy/module/__pypy__/interp_debug.py
@@ -1,5 +1,6 @@
 from pypy.interpreter.gateway import unwrap_spec
 from rpython.rlib import debug, jit
+from rpython.rlib import rtimer
 
 
 @jit.dont_look_inside
@@ -28,3 +29,6 @@
 @jit.dont_look_inside
 def debug_flush(space):
     debug.debug_flush()
+
+def debug_read_timestamp(space):
+    return space.newint(rtimer.read_timestamp())
diff --git a/pypy/module/__pypy__/test/test_debug.py b/pypy/module/__pypy__/test/test_debug.py
--- a/pypy/module/__pypy__/test/test_debug.py
+++ b/pypy/module/__pypy__/test/test_debug.py
@@ -48,3 +48,9 @@
         from __pypy__ import debug_flush
         debug_flush()
         # assert did not crash
+
+    def test_debug_read_timestamp(self):
+        from __pypy__ import debug_read_timestamp
+        a = debug_read_timestamp()
+        b = debug_read_timestamp()
+        assert b > a


More information about the pypy-commit mailing list