def do_tests(tests): for x in xrange(5): for func_name in tests: f = globals()[func_name] if isinstance(f, types.FunctionType): if f.func_name.startswith('test_'): coro.print_stderr('Running test %s...\n' % f.func_name) start_ram = mstats.get_malloc_stats()['allocated_bytes'] apply(f, ()) end_ram = mstats.get_malloc_stats()['allocated_bytes'] coro.print_stderr('RAM difference: %s\n' % comma_group(end_ram - start_ram)) coro._exit = 1
def _main(self): parser = optparse.OptionParser(usage=usage) parser.add_option('-v', '--verbose', action='count', help='Verbose output. Specify multiple times for more verbosity.' ) parser.add_option('--blocks', type='int', action='store', default=1048576, metavar=`1048576`, help='The size of the file in blocks.' ) parser.add_option('--num-writers', type='int', action='store', default=50, metavar=`50`, help='The number of writer threads.' ) parser.add_option('--num-readers', type='int', action='store', default=50, metavar=`50`, help='The number of reader threads.' ) parser.add_option('--max-num-blocks', type='int', action='store', default=100*1024, metavar=`100*1024`, help='The maximum number of blocks to write.' ) parser.add_option('--block-size', type='int', action='store', default=1, metavar=`1`, help='The size of a block.' ) parser.add_option('--duration', type='int', action='store', default=60, metavar=`60`, help='How long to run the test in seconds.' ) parser.add_option('--reader-delay', type='int', action='store', default=10000, metavar=`10000`, help='How many writes to wait to finish before starting the readers.' ) parser.add_option('--greediness', type='int', action='store', default=10, metavar=`10`, help='Number of consecutive reads or writes to perform before yielding.' ) parser.add_option('--cancel-percent', type='int', action='store', default=10, metavar=`10`, help='The percent of operations to try to cancel.' ) parser.add_option('--lio', action='store_true', help='Use LIO instead of AIO.' ) parser.add_option('--min-lio', type='int', action='store', default=1, metavar=`1`, help='The minimum number of events per LIO submit.' ) parser.add_option('--max-lio', type='int', action='store', default=MAX_LIO, metavar=`MAX_LIO`, help='The maximum number of events per LIO submit.' ) parser.add_option('--max-lio-size', type='int', action='store', default=MAX_LIO_SIZE, metavar=`MAX_LIO_SIZE`, help='The maximum size of a block of data in a LIO request. Do not change unless you know what you are doing. This is used instead of --max-num-blocks when using LIO.' ) parser.add_option('--num-lio-workers', type='int', action='store', default=50, metavar=`50`, help='The number of workers to use for LIO (used instead of --num-readers and --num-writers).' ) # blocked # interrupt percentage self.options, arguments = parser.parse_args() if len(arguments) != 1: parser.error('Must specify 1 argument.') # Check for valid settings. if self.options.lio: if not USING_LISTIO: parser.error('Unable to use LIO. Either lio_listio is not compiled, or the sysctl p1003_1b.aio_listio_max is not set.') if self.options.max_lio > MAX_LIO: parser.error('Maximum number of LIO events cannot be set above the p1003_1b.aio_listio_max sysctl value (currently %i).' % (MAX_LIO,)) if self.options.min_lio > self.options.max_lio: parser.error('--min-lio cannot be set above --max-lio') if self.options.max_lio_size % self.options.block_size: parser.error('--max-lio-size is not a multiple of --block-size') else: if self.options.max_num_blocks > self.options.blocks/2: parser.error('max_num_blocks cannot be greater than the file size divided by 2.') self._size = self.options.blocks * self.options.block_size self._write_locks = bintree.bintree((0, self._size)) self._read_locks = bintree.bintree((0, self._size)) self.path = arguments[0] self.main_thread_state = 'Creating file.' self.create() self.main_thread_state = 'Preparing file.' self.prep() if self.options.lio: self.start_lio() else: self.start_aio() print 'Write cancel success: %i' % (self._write_cancel_success,) print 'Write cancel failure: %i' % (self._write_cancel_fail,) print 'Read cancel success: %i' % (self._read_cancel_success,) print 'Read cancel failure: %i' % (self._read_cancel_fail,) print 'Total writes: %s (%s bytes)' % (comma_group(self._writes_finished), comma_group(self._bytes_written)) print 'Total reads: %s (%s bytes)' % (comma_group(self._reads_finished), comma_group(self._bytes_read)) print 'Assertion errors: %i' % (self._assertion_errors,)