[pypy-commit] pypy gc-hook-better-timestamp: expose the new debug_{start, stop} feature also to applevel, just because :)
antocuni
pypy.commits at gmail.com
Wed Apr 18 05:43:42 EDT 2018
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: gc-hook-better-timestamp
Changeset: r94374:5e1e87b1839e
Date: 2018-04-18 11:42 +0200
http://bitbucket.org/pypy/pypy/changeset/5e1e87b1839e/
Log: expose the new debug_{start,stop} feature also to applevel, just
because :)
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
@@ -3,9 +3,12 @@
from rpython.rlib import rtimer
@jit.dont_look_inside
- at unwrap_spec(category='text')
-def debug_start(space, category):
- debug.debug_start(category)
+ at unwrap_spec(category='text', timestamp=bool)
+def debug_start(space, category, timestamp=False):
+ res = debug.debug_start(category, timestamp=timestamp)
+ if timestamp:
+ return space.newint(res)
+ return space.w_None
@jit.dont_look_inside
def debug_print(space, args_w):
@@ -13,10 +16,12 @@
debug.debug_print(' '.join(parts))
@jit.dont_look_inside
- at unwrap_spec(category='text')
-def debug_stop(space, category):
- debug.debug_stop(category)
-
+ at unwrap_spec(category='text', timestamp=bool)
+def debug_stop(space, category, timestamp=False):
+ res = debug.debug_stop(category, timestamp=timestamp)
+ if timestamp:
+ return space.newint(res)
+ return space.w_None
@unwrap_spec(category='text')
def debug_print_once(space, category, args_w):
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
@@ -59,3 +59,15 @@
from __pypy__ import debug_get_timestamp_unit
unit = debug_get_timestamp_unit()
assert unit in ('tsc', 'ns', 'QueryPerformanceCounter')
+
+ def test_debug_start_stop_timestamp(self):
+ import time
+ from __pypy__ import debug_start, debug_stop, debug_read_timestamp
+ assert debug_start('foo') is None
+ assert debug_stop('foo') is None
+ ts1 = debug_start('foo', timestamp=True)
+ t = time.time()
+ while time.time() - t < 0.02:
+ pass
+ ts2 = debug_stop('foo', timestamp=True)
+ assert ts2 > ts1
More information about the pypy-commit
mailing list