[pypy-svn] r59906 - pypy/build/benchmem
xoraxax at codespeak.net
xoraxax at codespeak.net
Thu Nov 13 21:56:03 CET 2008
Author: xoraxax
Date: Thu Nov 13 21:56:02 2008
New Revision: 59906
Modified:
pypy/build/benchmem/runbench.py
Log:
Only run the actual function when run argument is used, generate less samples by employing busy looping/waiting.
Modified: pypy/build/benchmem/runbench.py
==============================================================================
--- pypy/build/benchmem/runbench.py (original)
+++ pypy/build/benchmem/runbench.py Thu Nov 13 21:56:02 2008
@@ -299,19 +299,34 @@
""", self.getbenchsource(), """
def init():
- %s %s
+ if len(sys.argv) > 1 and sys.argv[1] == 'run':
+ %s %s
sys.stdin.close()
""" %(name, arglist))
p = self.tmpdir.join("generatedbenchmark.py")
p.write(source)
return runner_file
-
+
def interact_with_child(self, rec, stdin, stdout):
while not stdin.closed:
try:
- self.write_internal_header({"TS": str(time.time())})
+ ts = time.time()
+ self.write_internal_header({"TS": str(ts)})
rec.snapshot()
+
+ # if we yielded to the scheduler via sleep(), the process
+ # under test would advance more than while we are running in
+ # our sampling code. instead of that, we do busy waiting here
+ # because some systems
+ # this program is used on only provide 20 hz sampling rate
+ # when doing no sleep at all.
+ # also we do not adjust the waiting time to the wall clock
+ # because this would give very different results based on
+ # the system speed. a better solution would be cpu timers
+ # or ptrace etc.
+ for _ in xrange(2**13):
+ pass
except py.error.ENOENT:
break
rec.stream.flush()
More information about the Pypy-commit
mailing list