Commits

Leonardo Soto committed c409a89

Added a 'warmup' feature for Jython, to let the JIT do its magic

Comments (0)

Files changed (2)

 
 # Defaults
 Number_of_rounds = 10
+Warmup_rounds = 5
 Warp_factor = 10
 
 # Import tests
                 'overhead calibration timing range too inaccurate: '
                 '%r - %r' % (min_overhead, max_overhead))
 
-    def run(self):
+    def run(self, warming_up=False):
 
         """ Run the test in two phases: first calibrate, then
             do the actual test. Be careful to keep the calibration
 
         """
         test = self.test
+        if warming_up:
+            test()
+            return
+
         timer = self.get_timer()
 
         # Get calibration
             print 'done.'
         print
 
+    def warmup(self):
+
+        tests = self.tests.items()
+        tests.sort()
+        if sys.platform.startswith('java'):
+            print "Warming up (%d rounds)..." % Setup.Warmup_rounds
+            for (name, test) in tests:
+                for x in xrange(Setup.Warmup_rounds):
+                    test.run(warming_up=True)
+
+
     def run(self):
 
         tests = self.tests.items()
         bench.rounds = rounds
         bench.load_tests(Setup, limitnames=limitnames)
         try:
+            bench.warmup()
             bench.calibrate()
             bench.run()
         except KeyboardInterrupt: