summaryrefslogtreecommitdiffstats
path: root/Lib/test/pystone.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-11-06 15:45:05 (GMT)
committerGuido van Rossum <guido@python.org>1997-11-06 15:45:05 (GMT)
commitc1189eb52421ff384d6d9252bb1acc03016051e3 (patch)
tree1f4c558fdfe3898b346e9d682448d3a629633c9b /Lib/test/pystone.py
parentf849291e2be019aa9976447ffc3b91033eeb37a8 (diff)
downloadcpython-c1189eb52421ff384d6d9252bb1acc03016051e3.zip
cpython-c1189eb52421ff384d6d9252bb1acc03016051e3.tar.gz
cpython-c1189eb52421ff384d6d9252bb1acc03016051e3.tar.bz2
Separate out a function pystones(loops=LOOPS) which runs the benchmark
and returns a (benchtime, stones) tuple. The main() function now calls this and prints the report. Fred Drake's code.
Diffstat (limited to 'Lib/test/pystone.py')
-rwxr-xr-xLib/test/pystone.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/Lib/test/pystone.py b/Lib/test/pystone.py
index 56e5c91..bef67d0 100755
--- a/Lib/test/pystone.py
+++ b/Lib/test/pystone.py
@@ -58,7 +58,14 @@ TRUE = 1
FALSE = 0
def main():
- Proc0()
+ benchtime, stones = pystones()
+ print "Pystone(%s) time for %d passes = %g" % \
+ (__version__, LOOPS, benchtime)
+ print "This machine benchmarks at %g pystones/second" % stones
+
+
+def pystones(loops=LOOPS):
+ return Proc0(loops)
IntGlob = 0
BoolGlob = FALSE
@@ -69,7 +76,7 @@ Array2Glob = map(lambda x: x[:], [Array1Glob]*51)
PtrGlb = None
PtrGlbNext = None
-def Proc0():
+def Proc0(loops=LOOPS):
global IntGlob
global BoolGlob
global Char1Glob
@@ -80,7 +87,7 @@ def Proc0():
global PtrGlbNext
starttime = clock()
- for i in range(LOOPS):
+ for i in range(loops):
pass
nulltime = clock() - starttime
@@ -96,7 +103,7 @@ def Proc0():
starttime = clock()
- for i in range(LOOPS):
+ for i in range(loops):
Proc5()
Proc4()
IntLoc1 = 2
@@ -121,10 +128,7 @@ def Proc0():
IntLoc1 = Proc2(IntLoc1)
benchtime = clock() - starttime - nulltime
- print "Pystone(%s) time for %d passes = %g" % \
- (__version__, LOOPS, benchtime)
- print "This machine benchmarks at %g pystones/second" % \
- (LOOPS/benchtime)
+ return benchtime, (loops / benchtime)
def Proc1(PtrParIn):
PtrParIn.PtrComp = NextRecord = PtrGlb.copy()