def test_iteratively_advance_time(): store = [] test_clock.set_timer("test", timedelta(seconds=1), handler=store.append) iterations = 1 PerformanceHarness.profile_function( TestClockHarness.iteratively_advance_time, 1, iterations)
async def run_test(): def submit_order(): order = self.strategy.order_factory.market( BTCUSDT_BINANCE.symbol, OrderSide.BUY, Quantity("1.00000000"), ) self.strategy.submit_order(order) PerformanceHarness.profile_function(submit_order, 10000, 1)
def test_advance_time(self): store = [] clock.set_timer("test", timedelta(seconds=1), handler=store.append) iterations = 1 result = PerformanceHarness.profile_function( TestClockTests.advance_time, 1, iterations) # ~1484ms (1484100μs) minimum of 1 runs @ 1000000 iterations each run. self.assertTrue(result < 2.0)
def test_advance_time(self): logger = LoggerAdapter('TestClock', TestLogger(level_console=LogLevel.DEBUG)) store = [] clock.register_logger(logger) clock.set_timer(Label('test'), timedelta(seconds=1), handler=store.append) iterations = 1 result = PerformanceHarness.profile_function(TestClockTests.advance_time, 1, iterations) # ~1036ms (1036473μs) minimum of 1 runs @ 1000000 iterations each run. self.assertTrue(result < 1.5)
def test_execute_command(self): order = self.strategy.order_factory.market( BTCUSDT_BINANCE.symbol, OrderSide.BUY, Quantity("1.00000000"), ) command = SubmitOrder( order.symbol.venue, self.trader_id, self.account_id, self.strategy.id, PositionId.null(), order, self.uuid_factory.generate(), self.clock.utc_now(), ) def execute_command(): self.exec_engine.execute(command) PerformanceHarness.profile_function(execute_command, 10000, 1)
def test_make_instrument_id(): PerformanceHarness.profile_function(ObjectTests.make_instrument_id, 100000, 1)
def test_make_symbol(): PerformanceHarness.profile_function(ObjectTests.make_symbol, 100000, 1)
def test_condition_true(): PerformanceHarness.profile_function(CorrectnessTests.true, 100000, 1)
def test_symbol_to_str(): PerformanceHarness.profile_function(ObjectTests.symbol_to_str, 100000, 1)
def test_advance_time(): PerformanceHarness.profile_function(TestClockHarness.advance_time, 100000, 1)
def test_utc_now(): PerformanceHarness.profile_function(live_clock.utc_now, 100000, 1)
def test_is_instance(): PerformanceHarness.profile_function(Experiments.is_instance, 100000, 1)
def test_is_message_type(): PerformanceHarness.profile_function(Experiments.is_message_type, 100000, 1)
def test_str_assignment(): PerformanceHarness.profile_function(Experiments.str_assignment, 100000, 1)
def test_class_name(): PerformanceHarness.profile_function(Experiments.class_name, 100000, 1)
def test_builtin_arithmetic(): PerformanceHarness.profile_function(Experiments.built_in_arithmetic, 100000, 1)
def test_instrument_id_to_str(): PerformanceHarness.profile_function(ObjectTests.instrument_id_to_str, 100000, 1)
def test_unix_timestamp_ns(): PerformanceHarness.profile_function(live_clock.timestamp_ns, 100000, 1)
def test_build_bar_with_checking(): PerformanceHarness.profile_function(ObjectTests.build_bar_with_checking, 100000, 1)
def test_order_id_generator(self): result = PerformanceHarness.profile_function(self.generator.generate, 3, 10000) # ~30ms (18831μs) minimum of 5 runs @ 10000 iterations self.assertTrue(result < 0.05)
def test_unix_time(): PerformanceHarness.profile_function(live_clock.unix_time, 100000, 1)
def test_build_bar_no_checking(self): result = PerformanceHarness.profile_function(ObjectTests.build_bar_no_checking, 3, 10000) # ~146ms (146283μs) minimum of 3 runs @ 100,000 iterations each run. # ~534ms (534113μs) minimum of 3 runs @ 100,000 iterations each run. self.assertTrue(result < 1.0)
def test_order_id_generator(self): PerformanceHarness.profile_function(self.generator.generate, 100000, 1)
def test_condition_not_none(): # Test PerformanceHarness.profile_function(CorrectnessTests.true, 3, 100000)
def test_symbol_using_to_string(self): result = PerformanceHarness.profile_function(ObjectTests.symbol_using_to_string, 3, 1000000) # ~103ms (103260μs) minimum of 3 runs @ 1,000,000 iterations each run. self.assertTrue(result < 0.2)
def test_limit_order_creation(self): PerformanceHarness.profile_function(self.create_limit_order, 10000, 1)
def test_build_bar_with_checking(self): result = PerformanceHarness.profile_function(ObjectTests.build_bar_with_checking, 3, 10000) # ~143ms (143914μs) minimum of 3 runs @ 100,000 iterations each run. # ~551ms (551233μs) minimum of 3 runs @ 100,000 iterations each run. self.assertTrue(result < 1.0)
def test_make_builtin_uuid(): PerformanceHarness.profile_function(uuid.uuid4, 100000, 1)
def test_condition_valid_string(): PerformanceHarness.profile_function(CorrectnessTests.valid_string, 100000, 1)
def test_make_nautilus_uuid(): PerformanceHarness.profile_function(uuid4, 100000, 1)