mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
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.
This commit is contained in:
parent
f849291e2b
commit
c1189eb524
1 changed files with 12 additions and 8 deletions
|
|
@ -58,7 +58,14 @@ TRUE = 1
|
||||||
FALSE = 0
|
FALSE = 0
|
||||||
|
|
||||||
def main():
|
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
|
IntGlob = 0
|
||||||
BoolGlob = FALSE
|
BoolGlob = FALSE
|
||||||
|
|
@ -69,7 +76,7 @@ Array2Glob = map(lambda x: x[:], [Array1Glob]*51)
|
||||||
PtrGlb = None
|
PtrGlb = None
|
||||||
PtrGlbNext = None
|
PtrGlbNext = None
|
||||||
|
|
||||||
def Proc0():
|
def Proc0(loops=LOOPS):
|
||||||
global IntGlob
|
global IntGlob
|
||||||
global BoolGlob
|
global BoolGlob
|
||||||
global Char1Glob
|
global Char1Glob
|
||||||
|
|
@ -80,7 +87,7 @@ def Proc0():
|
||||||
global PtrGlbNext
|
global PtrGlbNext
|
||||||
|
|
||||||
starttime = clock()
|
starttime = clock()
|
||||||
for i in range(LOOPS):
|
for i in range(loops):
|
||||||
pass
|
pass
|
||||||
nulltime = clock() - starttime
|
nulltime = clock() - starttime
|
||||||
|
|
||||||
|
|
@ -96,7 +103,7 @@ def Proc0():
|
||||||
|
|
||||||
starttime = clock()
|
starttime = clock()
|
||||||
|
|
||||||
for i in range(LOOPS):
|
for i in range(loops):
|
||||||
Proc5()
|
Proc5()
|
||||||
Proc4()
|
Proc4()
|
||||||
IntLoc1 = 2
|
IntLoc1 = 2
|
||||||
|
|
@ -121,10 +128,7 @@ def Proc0():
|
||||||
IntLoc1 = Proc2(IntLoc1)
|
IntLoc1 = Proc2(IntLoc1)
|
||||||
|
|
||||||
benchtime = clock() - starttime - nulltime
|
benchtime = clock() - starttime - nulltime
|
||||||
print "Pystone(%s) time for %d passes = %g" % \
|
return benchtime, (loops / benchtime)
|
||||||
(__version__, LOOPS, benchtime)
|
|
||||||
print "This machine benchmarks at %g pystones/second" % \
|
|
||||||
(LOOPS/benchtime)
|
|
||||||
|
|
||||||
def Proc1(PtrParIn):
|
def Proc1(PtrParIn):
|
||||||
PtrParIn.PtrComp = NextRecord = PtrGlb.copy()
|
PtrParIn.PtrComp = NextRecord = PtrGlb.copy()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue