def backend_base_open(test_object, suffix, schema_source, schema_version): """Perform the actual opening of a database, then return it. - `test_object`: The instance of the test class we're opening a database for. - `suffix`: The suffix to use on variable names when storing open databases and auxiliary information. - `schema_source`: Schema source code to use. - `schema_version`: Version of the schema to use. """ db_name = 'db' + suffix contents = TestMethods_CreatesDatabase.backend_db_contents( test_object, suffix) fp = StringIO(contents) if len(contents) == 0: db = database.create( filename=None, backend_name='schevo.store', backend_args=dict(fp=fp, cache_size=100000), schema_source=schema_source, schema_version=schema_version, format=test_object.format, ) else: db = database.open( filename=None, backend_name='schevo.store', backend_args=dict(fp=fp, cache_size=100000), ) setattr(test_object, db_name, db) setattr(test_object, 'fp' + suffix, fp) return db
def backend_base_open(test_object, suffix, schema_source, schema_version): """Perform the actual opening of a database, then return it. - `test_object`: The instance of the test class we're opening a database for. - `suffix`: The suffix to use on variable names when storing open databases and auxiliary information. - `schema_source`: Schema source code to use. - `schema_version`: Version of the schema to use. """ db_name = 'db' + suffix filename = getattr(test_object, 'filename' + suffix, None) if filename is None: filename = random_filename() db = database.create( filename = filename, backend_name = 'durus', backend_args = test_object.backend_args, schema_source = schema_source, schema_version = schema_version, format = test_object.format, ) else: db = database.open( filename = filename, backend_name = 'durus', backend_args = test_object.backend_args, ) setattr(test_object, db_name, db) setattr(test_object, 'filename' + suffix, filename) return db
def main(self, arg0, args): print print parser = _parser() options, args = parser.parse_args(list(args)) if len(args) == 0: print 'At least one NAME, or "list"/"report", must be specified.' return 1 if len(args) == 1 and args[0].lower() == 'list': print 'Available benchmarks:' print for name, value in sorted(benchmark_map.items()): if isinstance(value, basestring): print name else: print '%s %r' % (name, value) else: if options.repeat < 1: print 'COUNT must be >= 1, not %i.' % options.repeat return 1 if options.backend_name is None: print 'NOTE: Using schevo.store backend.' print options.backend_name = 'schevo.store' db = None if options.database is not None: print 'Opening database %r.' % options.database db = database.open(options.database) machine = db.Machine.x.this() print 'Machine is %s (OID %r)' % (machine, machine.sys.oid) names = [arg.lower() for arg in args] package_names = benchmark_package_names(names) print 'Preparing to run these benchmarks:' for package_name in package_names: print ' %s' % package_name print print 'Backend name:', options.backend_name print 'Backend args:', options.backend_args print for package_name in package_names: print package_name print '=' * len(package_name) runner = BenchmarkRunner( package_name, options.backend_name, options.backend_args) for count in xrange(options.repeat): print 'Starting repetition %i.' % (count + 1) runner.run() print 'Finished.' if db: runner.store_in(db, machine) print 'Stored results.' print 'Best times:' pprint(runner.best_times()) print