def test_call(): test_call0 = x64.compile(call0) assert test_call0(load_const) == 100 test_call1 = x64.compile(call1) assert test_call1(identity, 'testing') == 'testing' test_call3 = x64.compile(call3) assert test_call3(get_third, 1, 2, 3) == 3
def test_is_not(): def f(x, y): return x is not y test = x64.compile(f) assert test(1, 1) == False assert test(1, 2) == True
if taskWorkArea.holdCount == 9297 and taskWorkArea.qpktCount == 23246: pass else: return False return True if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--num-iters', default=1, type=int) parser.add_argument('--use-jit', action='store_true') parser.add_argument('--report', action='store_true') args = parser.parse_args() richards = Richards() if args.use_jit: cinder.install_interpreter() TaskState.isTaskHoldingOrWaiting = x64.compile( TaskState.isTaskHoldingOrWaiting) TaskState.isWaitingWithPacket = x64.compile( TaskState.isWaitingWithPacket) Task.runTask = x64.compile(Task.runTask) schedule = x64.compile(schedule) start = time.time() richards.run(args.num_iters) elapsed = time.time() - start if args.report: print(f'Took {elapsed}s') if args.use_jit: cinder.uninstall_interpreter()
def test_load_attr(): x = x64.compile(get_bar) foo = Foo('testing 123') assert x(foo) == 'testing 123'
def test_load_fast_and_return_value(): foo = x64.compile(identity) assert foo(100) == 100
def test_is(): test = x64.compile(cmp_is) assert test(1, 1) == True assert test(1, 2) == False
def test_jump_forward(): test = x64.compile(jump_forward) assert test(True, True) == 1 assert test(True, False) == None assert test(False, False) == 2
def test_while_loop(): test = x64.compile(while_loop) assert test(True, 0) == 0
def test_store(): test = x64.compile(store_local) assert test(10) == 10
def test_store_attr(): test = x64.compile(set_bar) foo = Foo(None) test(foo, 'testing 123') assert foo.bar == 'testing 123'
def test_load_global(): test = x64.compile(load_global) assert test() == 'testing 123'
def test_load_const(): test = x64.compile(load_const) assert test() == 100
def test_jump_if_false(): test = x64.compile(jump_if_false) assert test(False, 1) == False assert test(True, 1) == 1 assert test(0, 'foo') == 0 assert test(1, 'bar') == 'bar'
def test_jump_if_true(): test = x64.compile(jump_if_true) assert test(True, False) == True assert test(False, 1) == 1 assert test(0, 'foo') == 'foo' assert test(1, 'bar') == 1
def test_pop_jump(): test = x64.compile(pop_jump) assert test(True, 1, 2) == 1 assert test(False, 1, 2) == 2 assert test(1, 'foo', 'bar') == 'foo' assert test(0, 'foo', 'bar') == 'bar'
def test_invert(): x64_invert = x64.compile(invert) assert x64_invert(False) == True assert x64_invert(True) == False assert x64_invert(1) == False