summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAlex Martelli <aleaxit@gmail.com>2004-01-02 17:11:54 (GMT)
committerAlex Martelli <aleaxit@gmail.com>2004-01-02 17:11:54 (GMT)
commitb993b067d282f825a68cb2c2a5cdd090a6057f77 (patch)
tree4c4db0f1dca2cce3918b592b95ab64fa9a56eaa8 /Lib
parent6e4f7a82da178c7c69dc8cbe65284bf7d1bb5a61 (diff)
downloadcpython-b993b067d282f825a68cb2c2a5cdd090a6057f77.zip
cpython-b993b067d282f825a68cb2c2a5cdd090a6057f77.tar.gz
cpython-b993b067d282f825a68cb2c2a5cdd090a6057f77.tar.bz2
The script now takes an optional command-line argument to specify how many
loops to run (default remains 50,000 if no argument is specified).
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/pystone.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/Lib/test/pystone.py b/Lib/test/pystone.py
index 931a307..168c399 100755
--- a/Lib/test/pystone.py
+++ b/Lib/test/pystone.py
@@ -57,10 +57,10 @@ class Record:
TRUE = 1
FALSE = 0
-def main():
- benchtime, stones = pystones()
+def main(loops=LOOPS):
+ benchtime, stones = pystones(loops)
print "Pystone(%s) time for %d passes = %g" % \
- (__version__, LOOPS, benchtime)
+ (__version__, loops, benchtime)
print "This machine benchmarks at %g pystones/second" % stones
@@ -249,4 +249,19 @@ def Func3(EnumParIn):
return FALSE
if __name__ == '__main__':
- main()
+ import sys
+ def error(msg):
+ print >>sys.stderr, msg,
+ print >>sys.stderr, "usage: %s [number_of_loops]" % sys.argv[0]
+ sys.exit(100)
+ nargs = len(sys.argv) - 1
+ if nargs > 1:
+ error("%d arguments are too many;" % nargs)
+ elif nargs == 1:
+ try: loops = int(sys.argv[1])
+ except ValueError:
+ error("Invalid argument %r;" % sys.argv[1])
+ else:
+ loops = LOOPS
+ main(loops)
+