Exemplo n.º 1
0
def bench_ping_pong_nodegroup():
    # compare Qt4 mainloop of NodeGroup vs Host main loop which is infinite loop (fastest possible)
    for name, class_ in [ ('Host', Host), ('NodeGroup', NodeGroup)]:
        addr = 'tcp://127.0.0.1:*'
        process  = ProcessSpawner(class_,  name, addr)
        client = RPCClient(name, process.addr)
        
        N =1000
        
        t1 = time.time()
        for i in range(N):
            client.ping()
        t2 = time.time()
        print(name, ' : sync ping per second', N/(t2-t1))

        t1 = time.time()
        rets = []
        for i in range(N):
            rets.append(client.ping(_sync=False))
        for ret in rets:
            ret.result()
        t2 = time.time()
        print(name, ' : async ping per second', N/(t2-t1))
        
        client.close()
Exemplo n.º 2
0
def test_host1():
    
    process_host0 = ProcessSpawner(Host, 'host0', 'tcp://127.0.0.1:*')
    process_host1 = ProcessSpawner(Host, 'host1', 'tcp://127.0.0.1:*')
    
    client0 = RPCClient('host0', process_host0.addr)
    print('on ping: ', client0.ping())
    
    time.sleep(1.)
    
    process_host0.stop()
    process_host1.stop()