Example #1
0
def main():
    random.seed(0)

    d = Driver()
    t = Transport(d, isServer=False)
    services = Services(t)
    s = services.getService(TEST_ADDRESS)

    for i in itertools.count(1):
        #totalFrags = random.randrange(1, 2**16 - 1)
        totalFrags = random.randrange(1, 500)
        #totalFrags = 1000
        requestBuffer = Buffer(
            ['a' * t.dataPerFragment() for j in range(totalFrags)])
        responseBuffer = Buffer()
        start = gettime()
        r = t.clientSend(s, requestBuffer, responseBuffer)
        r.getReply()
        elapsedNs = gettime() - start
        resp = responseBuffer.getRange(0, responseBuffer.getTotalLength())
        req = requestBuffer.getRange(0, requestBuffer.getTotalLength())
        assert len(req) == len(resp), (len(req), len(resp), req[:10],
                                       resp[:10], req[-10:], resp[-10:])
        assert req == resp, (req, resp)
        print
        print "Message %d with %d frags OK in %dms" % (i, totalFrags,
                                                       elapsedNs / 1000000)
        d.stat()
Example #2
0
def main():
    random.seed(0)

    d = Driver()
    t = Transport(d, isServer=False)
    services = Services(t)
    s = services.getService(TEST_ADDRESS)

    for i in itertools.count(1):
        #totalFrags = random.randrange(1, 2**16 - 1)
        totalFrags = random.randrange(1, 500)
        #totalFrags = 1000
        requestBuffer = Buffer(['a' * t.dataPerFragment() for j in range(totalFrags)])
        responseBuffer = Buffer()
        start = gettime()
        r = t.clientSend(s, requestBuffer, responseBuffer)
        r.getReply()
        elapsedNs = gettime() - start
        resp = responseBuffer.getRange(0, responseBuffer.getTotalLength())
        req = requestBuffer.getRange(0, requestBuffer.getTotalLength())
        assert len(req) == len(resp), (len(req), len(resp), req[:10], resp[:10],
                                       req[-10:], resp[-10:])
        assert req == resp, (req, resp)
        print
        print "Message %d with %d frags OK in %dms" % (i, totalFrags,
                                                       elapsedNs / 1000000)
        d.stat()
Example #3
0
def main():
    d = Driver(TEST_ADDRESS)
    t = Transport(d, isServer=True)
    while True:
        r = t.serverRecv()
        r.replyPayload.extend(r.recvPayload)
        r.sendReply()
        d.stat()
Example #4
0
def main():
    d = Driver(TEST_ADDRESS)
    t = Transport(d, isServer=True)
    while True:
        r = t.serverRecv()
        r.replyPayload.extend(r.recvPayload)
        r.sendReply()
        d.stat()