TODO:
* Incorporate the changes made by (see Inbox)
- * Add number range option using srange()
+ * Add number range option using srange()
"""
""" Option that takes an argument.
An optional default argument can be given.
-
+
"""
def __init__(self,name,help=None,default=None):
values = None # Dictionary of passed options (or default values)
# indexed by the options name, e.g. '-h'
files = None # List of passed filenames
- optionlist = None # List of passed options
+ optionlist = None # List of passed options
def __init__(self,argv=None):
# Init .arguments list
self.arguments = argv[1:]
-
+
# Setup Option mapping
self.option_map = option_dict(self.options)
-
+
# Append preset options
for option in self.preset_options:
if not self.option_map.has_key(option.name):
self.add_option(option)
-
+
# Init .files list
self.files = []
rc = self.startup()
if rc is not None:
raise SystemExit,rc
-
+
# Parse command line
rc = self.parse()
if rc is not None:
raise SystemExit,rc
-
+
# Start application
rc = self.main()
if rc is None:
Note that this has to be done *before* .parse() is being
executed.
-
+
"""
self.options.append(option)
self.option_map[option.name] = option
This may modify filelist in place. A typical application
is checking that at least n files are given.
-
+
If this method returns anything other than None, the
process is terminated with the return value as exit code.
-
+
"""
return None
""" This may process the files list in place.
"""
return None
-
+
# Short option handler
def handle_h(self,arg):
self.help()
return 0
-
+
def handle_v(self, value):
""" Turn on verbose output.
"""
self.verbose = 1
-
+
# Handlers for long options have two underscores in their name
def handle__help(self,arg):
it is None, 0 is assumed (meaning OK). Unhandled
exceptions are reported with exit status code 1 (see
__init__ for further details).
-
+
"""
return None
header = 'Test Application'
version = __version__
options = [Option('-v','verbose')]
-
+
def handle_v(self,arg):
print 'VERBOSE, Yeah !'
2 == 3
2 > 3
2 < 3
-
+
2 < 3
2 > 3
2 == 3
2 > 3
2 < 3
-
+
2 < 3
2 > 3
2 == 3
2 > 3
2 < 3
-
+
2 < 3
2 > 3
2 == 3
2 > 3
2 < 3
-
+
2 < 3
2 > 3
2 == 3
2 > 3
2 < 3
-
+
2 < 3
2 > 3
2 == 3
2 > 3
2 < 3
-
+
2 < 3
2 > 3
2 == 3
2 > 3
2 < 3
-
+
2 < 3
2 > 3
2 == 3
2 > 3
2 < 3
-
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1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
2.1 == 3.31
2.1 > 3.31
2.1 < 3.31
-
+
2.1 < 3.31
2.1 > 3.31
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1 > 4
2.1 < 4
-
+
2.1 < 4
2.1 > 4
2.1 == 4
2.1 > 4
2.1 < 4
-
+
2.1 < 4
2.1 > 4
2.1 == 4
2.1 > 4
2.1 < 4
-
+
2.1 < 4
2.1 > 4
2.1 == 4
2.1 > 4
2.1 < 4
-
+
2.1 < 4
2.1 > 4
2.1 == 4
2.1 > 4
2.1 < 4
-
+
2.1 < 4
2.1 > 4
2.1 == 4
2.1 > 4
2.1 < 4
-
+
2.1 < 4
2.1 > 4
2.1 == 4
2.1 > 4
2.1 < 4
-
+
2.1 < 4
2.1 > 4
2.1 == 4
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
1234567890L > 3456789012345L
1234567890L < 3456789012345L
-
+
1234567890L < 3456789012345L
1234567890L > 3456789012345L
1234567890L == 3456789012345L
for i in xrange(self.rounds):
pass
-
+
class CompareUnicode(Test):
for i in xrange(self.rounds):
pass
-
+
class CreateUnicodeWithConcat(Test):
for i in xrange(self.rounds):
pass
-
+
class UnicodeSlicing(Test):
for i in xrange(self.rounds):
pass
-
+
### String methods
class UnicodeMappings(Test):
t = join(map(unichr,range(100)),'')
u = join(map(unichr,range(500)),'')
v = join(map(unichr,range(1000)),'')
-
+
for i in xrange(self.rounds):
s.lower()
t = join(map(unichr,range(100)),'')
u = join(map(unichr,range(500)),'')
v = join(map(unichr,range(1000)),'')
-
+
for i in xrange(self.rounds):
pass
data = (u'abc', u'123', u' ', u'\u1234\u2345\u3456', u'\uFFFF'*10)
len_data = len(data)
-
+
for i in xrange(self.rounds):
s = data[i % len_data]
data = (u'abc', u'123', u' ', u'\u1234\u2345\u3456', u'\uFFFF'*10)
len_data = len(data)
-
+
for i in xrange(self.rounds):
s = data[i % len_data]
__version__ = '1.3'
#
-# NOTE: Use xrange for all test loops unless you want to face
+# NOTE: Use xrange for all test loops unless you want to face
# a 20MB process !
#
# All tests should have rounds set to values so that a run()
# for comparisons of benchmark runs - tests with unequal version
# number will not get compared.
version = 1.0
-
+
# The number of abstract operations done in each round of the
# test. An operation is the basic unit of what you want to
# measure. The benchmark will output the amount of run-time per
""" Run the test in two phases: first calibrate, then
do the actual test. Be careful to keep the calibration
timing low w/r to the test timing.
-
+
"""
test = self.test
calibrate = self.calibrate
offset = offset + t
offset = offset / cruns
# now the real thing
- t = clock()
+ t = clock()
test()
t = clock() - t
self.last_timing = (t-offset,t,offset)
def calibrate(self):
- """ Calibrate the test.
+ """ Calibrate the test.
- This method should execute everything that is needed to
- setup and run the test - except for the actual operations
- that you intend to measure. pybench uses this method to
- measure the test implementation overhead.
+ This method should execute everything that is needed to
+ setup and run the test - except for the actual operations
+ that you intend to measure. pybench uses this method to
+ measure the test implementation overhead.
"""
return
def test(self):
- """ Run the test.
+ """ Run the test.
- The test needs to run self.rounds executing
- self.operations number of operations each.
+ The test needs to run self.rounds executing
+ self.operations number of operations each.
"""
# do some tests
return
-
+
def stat(self):
""" Returns two value: average time per run and average per
operation.
-
+
"""
runs = len(self.times)
if runs == 0:
roundtime = 0 # Average round time
version = None # Benchmark version number (see __init__)
# as float x.yy
- starttime = None # Benchmark start time
+ starttime = None # Benchmark start time
def __init__(self):
print
self.roundtime = (clock() - roundtime) / self.rounds
print
-
+
def print_stat(self, compare_to=None, hidenoise=0):
if not compare_to:
hidenoise = self.values['-d']
warp = self.values['-w']
nogc = self.values['--no-gc']
-
+
# Switch off GC
if nogc:
try:
compare_to = bench
except IOError:
print '* Error opening/reading file',compare_to
- compare_to = None
+ compare_to = None
if show_bench:
try: