Permalink
Browse files

Merge pull request #184 from geekless/speed.py-fixes

speed.py fixes
  • Loading branch information...
2 parents f53af9c + 17d4ca8 commit d2105a201f79323c5b64438950c0624b061a65e2 @stevedekorte stevedekorte committed Apr 10, 2012
Showing with 12 additions and 8 deletions.
  1. +12 −8 samples/speed/speed.py
View
20 samples/speed/speed.py
@@ -3,6 +3,10 @@
oneMillion = 1000000
+if sys.version_info >= (3,):
+ def xrange(v):
+ return range(int(v))
+
class Tester:
def foo(self):
return 1
@@ -12,7 +16,7 @@ def beginTimer(self):
def endTimer(self, s):
mps = 1/(time.time() - self.t1)
- print "Python %s := %0.2f" % (s, mps)
+ print("Python %s := %0.2f" % (s, mps))
def testSlot(self):
self.beginTimer()
@@ -61,21 +65,21 @@ def testSetLocals(self):
self.endTimer("localSets ")
def test(self):
- print ""
+ print("")
self.testLocals()
self.testSetLocals()
- print ""
+ print("")
self.testSlot()
self.testSetSlot()
- print ""
+ print("")
self.testBlock()
self.testInstantiations()
import sys
- print "Python version := \"%i.%i.%i %s %i\"" % sys.version_info
- print ""
- print "// values in millions per second"
- print ""
+ print("Python version := \"%i.%i.%i %s %i\"" % tuple(sys.version_info))
+ print("")
+ print("// values in millions per second")
+ print("")
Tester().test()

0 comments on commit d2105a2

Please sign in to comment.