def test_runtime_3(self): sw = StopWatch() sw.start() time.sleep(2) assert round(sw.time) == 2.0 time.sleep(2) assert round(sw.time) == 4.0
def test_lap_3(self): sw = StopWatch() sw.start() time.sleep(1) assert round(sw.lap.time) == 1.0 time.sleep(3) assert round(sw.lap.time) == 3.0 assert sw[0].nlaps == 2
def test_runtime_5(self): sw = StopWatch() sw.start() time.sleep(2) time.sleep(1) sw.stop() time.sleep(2) sw.start() time.sleep(1) sw.stop() assert round(sw.time) == 4.0
def test_stop_2(self): sw = StopWatch() sw.start() time.sleep(1) sw.stop() assert round(sw.time) == 1.0 time.sleep(1) sw.start() time.sleep(2) sw.stop() assert round(sw.time) == 3.0 assert sw.nintervals == 2
def test_reset_1(self): sw = StopWatch() sw.start() time.sleep(2) sw.stop() assert round(sw.time) == 2.0 sw.reset() assert round(sw.time) == 0.0
def test_lap_4(self): sw = StopWatch() sw.start() time.sleep(1) assert round(sw.lap.time) == 1.0 time.sleep(3) assert round(sw.lap.time) == 3.0 sw.stop() time.sleep(1) sw.start() time.sleep(2) assert round(sw.lap.time) == 2.0 sw.stop() assert sw.nintervals == 2 assert sw[0].nlaps == 2 assert sw[1].nlaps == 1
def test_context_3(self): with StopWatch() as sw: time.sleep(3) sw.stop() time.sleep(2) sw.start() time.sleep(1) assert round(sw.time) == 4.0 assert [round(interval.time) for interval in sw.intervals] == [3.0, 1.0]
def test_stop_1(self): sw = StopWatch() sw.start() time.sleep(1) sw.stop() assert not sw.running assert round(sw.time) == 1.0
def main(): """SIMBAD database creation function""" p = create_db_argparse() args = p.parse_args() global logger log_class = simbad.command_line.LogController() log_class.add_console(level=args.debug_lvl) logger = log_class.get_logger() simbad.command_line.print_header() stopwatch = StopWatch() stopwatch.start() if args.which == "lattice": create_lattice_db(args.latt_db) elif args.which == "contaminant": create_contaminant_db(args.cont_db, args.add_morda_domains, nproc=args.nproc, submit_qtype=args.submit_qtype, submit_queue=args.submit_queue) elif args.which == "morda": create_morda_db(args.simbad_db, nproc=args.nproc, submit_qtype=args.submit_qtype, submit_queue=args.submit_queue, chunk_size=args.chunk_size) elif args.which == "ensemble": create_ensemble_db(args.ensemble_db, pdb_db=args.pdb_db, nproc=args.nproc, submit_qtype=args.submit_qtype, submit_queue=args.submit_queue, chunk_size=args.chunk_size) elif args.which == "custom": create_db_custom(args.input_db, args.custom_db) elif args.which == "validate": if os.path.isdir(args.database): validate_compressed_database(args.database) else: logger.critical("Unable to validate the following database: %s", args.database) stopwatch.stop() logger.info( "Database creation completed in %d days, %d hours, %d minutes, and %d seconds", *stopwatch.time_pretty) log_class.close()
def test_start_1(self): assert StopWatch().time == 0
def test_lap_1(self): assert StopWatch().lap is None
def test_context_2(self): with StopWatch() as sw: time.sleep(3) sw.stop() time.sleep(2) assert round(sw.time) == 3.0
def test_context_1(self): with StopWatch() as sw: time.sleep(3) assert round(sw.time) == 3.0
def test_convert_2(self): sw = StopWatch() sw.start() time.sleep(5) sw.stop() assert sw.time_pretty == (0, 0, 0, 5)
def test_start_2(self): sw = StopWatch() sw.start() assert sw.running time.sleep(1) assert round(sw.time) == 1.0