コード例 #1
0
ファイル: test_service.py プロジェクト: ipatrol/socketless
    def testInProcessSingleService_Sync(self):
        print
        print 'testInProcessSingleService_Sync'
        N = 1000
        listener = ('localhost', 16000)
        server = Server(listener, [StoreService()])
        server.serve()
        self.servers.append(server)
        store_client = Client(listener, StoreProtocol())
        store_client.connect()
        self.clients.append(store_client)
        while not store_client.is_connected():
            coio.sleep(0.01)
        coio.stackless.schedule()

        values = [('foo%d' % i, i, 'bar%d' % i) for i in xrange(N)]
        received_values = []

        start = time.time()
        for key, timestamp, value in values:
            retreived_timestamp = store_client.set(key, timestamp, value)
            assert retreived_timestamp == timestamp
            received_values.append(store_client.get(key))
        elapsed = time.time() - start

        for (key, timestamp,
             value), (received_timestamp,
                      received_value) in zip(values, received_values):
            assert timestamp == received_timestamp
            assert value == received_value

        print 'Elapsed: %.2fs' % elapsed
        print '%.2f invocations / s' % (2 * N / elapsed)
コード例 #2
0
    def testInProcessSingleService_Sync(self):
        print
        print "testInProcessSingleService_Sync"
        N = 1000
        listener = ("localhost", 16000)
        server = Server(listener, [StoreService()])
        server.serve()
        self.servers.append(server)
        store_client = Client(listener, StoreProtocol())
        store_client.connect()
        self.clients.append(store_client)
        while not store_client.is_connected():
            coio.sleep(0.01)
        coio.stackless.schedule()

        values = [("foo%d" % i, i, "bar%d" % i) for i in xrange(N)]
        received_values = []

        start = time.time()
        for key, timestamp, value in values:
            retreived_timestamp = store_client.set(key, timestamp, value)
            assert retreived_timestamp == timestamp
            received_values.append(store_client.get(key))
        elapsed = time.time() - start

        for (key, timestamp, value), (received_timestamp, received_value) in zip(values, received_values):
            assert timestamp == received_timestamp
            assert value == received_value

        print "Elapsed: %.2fs" % elapsed
        print "%.2f invocations / s" % (2 * N / elapsed)
コード例 #3
0
ファイル: test_service.py プロジェクト: ipatrol/socketless
 def testInterProcessSingleService(self):
     print
     print 'testInterProcessSingleService'
     N = 1000
     self.registerSubprocess(spawn_server(16300))
     listener = ('localhost', 16300)
     store_client = Client(listener, StoreProtocol())
     store_client.connect()
     self.clients.append(store_client)
     while not store_client.is_connected():
         coio.sleep(0.01)
     values = [('foo%d' % i, i, 'bar%d' % i) for i in xrange(N)]
     received_values = []
     start = time.time()
     for key, timestamp, value in values:
         store_client.set(key, timestamp, value)
         received_values.append(store_client.get(key))
     elapsed = time.time() - start
     for (key, timestamp,
          value), (received_timestamp,
                   received_value) in zip(values, received_values):
         assert timestamp == received_timestamp
         assert value == received_value
     print 'Elapsed: %.2fs' % elapsed
     print '%.2f invocations / s' % (2 * N / elapsed)
コード例 #4
0
 def testInterProcessSingleService(self):
     print
     print "testInterProcessSingleService"
     N = 1000
     self.registerSubprocess(spawn_server(16300))
     listener = ("localhost", 16300)
     store_client = Client(listener, StoreProtocol())
     store_client.connect()
     self.clients.append(store_client)
     while not store_client.is_connected():
         coio.sleep(0.01)
     values = [("foo%d" % i, i, "bar%d" % i) for i in xrange(N)]
     received_values = []
     start = time.time()
     for key, timestamp, value in values:
         store_client.set(key, timestamp, value)
         received_values.append(store_client.get(key))
     elapsed = time.time() - start
     for (key, timestamp, value), (received_timestamp, received_value) in zip(values, received_values):
         assert timestamp == received_timestamp
         assert value == received_value
     print "Elapsed: %.2fs" % elapsed
     print "%.2f invocations / s" % (2 * N / elapsed)