[pypy-commit] extradoc extradoc: measure fps, pypy is 70 times faster than cpython here
hakanardo
noreply at buildbot.pypy.org
Thu Sep 13 20:04:45 CEST 2012
Author: Hakan Ardo <hakan at debian.org>
Branch: extradoc
Changeset: r4812:98f94d389f25
Date: 2012-09-13 20:03 +0200
http://bitbucket.org/pypy/extradoc/changeset/98f94d389f25/
Log: measure fps, pypy is 70 times faster than cpython here
diff --git a/talk/dls2012/demo/demo.py b/talk/dls2012/demo/demo.py
old mode 100644
new mode 100755
--- a/talk/dls2012/demo/demo.py
+++ b/talk/dls2012/demo/demo.py
@@ -1,5 +1,5 @@
from subprocess import call, Popen
-import os, time, re
+import os, time, re, sys
class Vim(object):
def __init__(self, *args):
@@ -18,9 +18,9 @@
self.send('<ESC>:q!<CR>')
def pause(msg=''):
- print
+ print "\n"
print msg
- raw_input('Press ENTER')
+ raw_input('Press ENTER\n')
def demo():
with open('analytics.py', 'w') as fd:
@@ -32,7 +32,7 @@
def update(self, frame):
view(frame)
"""
- runner = Popen(['pypy', 'run.py', 'demo.avi'])
+ runner = Popen([sys.executable, 'run.py', 'demo.avi'])
vim = Vim('analytics.py')
pause("We'r looking at the input and output of this Tracker object that\n" +
diff --git a/talk/dls2012/demo/run.py b/talk/dls2012/demo/run.py
--- a/talk/dls2012/demo/run.py
+++ b/talk/dls2012/demo/run.py
@@ -1,16 +1,26 @@
from io import mplayer, view
from analytics import Tracker
-import sys
+import sys, time
if len(sys.argv) > 1:
fn = sys.argv[1]
else:
fn = 'demo.avi'
+t0 = time.time()
+fcnt = 0
+
tracker = Tracker()
while True:
for img in mplayer(fn):
view(img, 'Input')
tracker.update(img)
+ t1 = time.time()
+ if t1 - t0 > 1:
+ print >>sys.stderr, '\r%f fps' % (fcnt / (t1-t0)),
+ t0 = t1
+ fcnt = 0
+ fcnt += 1
+
More information about the pypy-commit
mailing list