[pypy-commit] pypy stmgc-c7: Test and fix for EmptyProfiler
arigo
noreply at buildbot.pypy.org
Sat Mar 21 10:33:17 CET 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r76486:fd630b2807a8
Date: 2015-03-21 09:21 +0100
http://bitbucket.org/pypy/pypy/changeset/fd630b2807a8/
Log: Test and fix for EmptyProfiler
diff --git a/rpython/jit/metainterp/jitprof.py b/rpython/jit/metainterp/jitprof.py
--- a/rpython/jit/metainterp/jitprof.py
+++ b/rpython/jit/metainterp/jitprof.py
@@ -44,7 +44,10 @@
pass
def get_counter(self, num):
- return -1.0
+ return 0
+
+ def get_times(self, num):
+ return 0.0
class Profiler(BaseProfiler):
initialized = False
@@ -109,6 +112,9 @@
return self.cpu.tracker.total_freed_bridges
return self.counters[num]
+ def get_times(self, num):
+ return self.times[num]
+
def count_ops(self, opnum, kind=Counters.OPS):
from rpython.jit.metainterp.resoperation import rop
self.counters[kind] += 1
diff --git a/rpython/jit/metainterp/test/test_jitiface.py b/rpython/jit/metainterp/test/test_jitiface.py
--- a/rpython/jit/metainterp/test/test_jitiface.py
+++ b/rpython/jit/metainterp/test/test_jitiface.py
@@ -5,7 +5,7 @@
from rpython.jit.codewriter.policy import JitPolicy
from rpython.jit.metainterp.resoperation import rop
from rpython.rtyper.annlowlevel import hlstr
-from rpython.jit.metainterp.jitprof import Profiler
+from rpython.jit.metainterp.jitprof import Profiler, EmptyProfiler
class JitHookInterfaceTests(object):
@@ -178,6 +178,20 @@
self.meta_interp(main, [], ProfilerClass=Profiler)
+ def test_get_stats_empty(self):
+ driver = JitDriver(greens = [], reds = ['i'])
+ def loop(i):
+ while i > 0:
+ driver.jit_merge_point(i=i)
+ i -= 1
+ def main():
+ loop(30)
+ assert jit_hooks.stats_get_counter_value(None,
+ Counters.TOTAL_COMPILED_LOOPS) == 0
+ assert jit_hooks.stats_get_times_value(None, Counters.TRACING) == 0
+ self.meta_interp(main, [], ProfilerClass=EmptyProfiler)
+
+
class LLJitHookInterfaceTests(JitHookInterfaceTests):
# use this for any backend, instead of the super class
diff --git a/rpython/rlib/jit_hooks.py b/rpython/rlib/jit_hooks.py
--- a/rpython/rlib/jit_hooks.py
+++ b/rpython/rlib/jit_hooks.py
@@ -130,7 +130,7 @@
@register_helper(annmodel.SomeFloat())
def stats_get_times_value(warmrunnerdesc, no):
- return warmrunnerdesc.metainterp_sd.profiler.times[no]
+ return warmrunnerdesc.metainterp_sd.profiler.get_times(no)
LOOP_RUN_CONTAINER = lltype.GcArray(lltype.Struct('elem',
('type', lltype.Char),
More information about the pypy-commit
mailing list