Exemple #1
0
def encodingTiming():
    print "#=============== END-TO-END ENCODING =================="
    shortP = "hello world"
    prng = AESCounterPRNG()
    p = encodeMessage(shortP, 0, prng)[0]
    t = prng.getBytes(20)
    print "Check short payload", timeit(
        lambda p=p: mixminion.BuildMessage._checkPayload(p), 1000)
    print "Decode without uncompress", timeit(
        lambda p=p,t=t: decodePayload(p, t), 1000)
    print "Decode short payload", timeit(
        lambda p=p,t=t: decodePayload(p, t).getUncompressedContents(), 1000)

    k20 = prng.getBytes(20*1024)
    p = encodeMessage(k20, 0, prng)[0]
    t = prng.getBytes(20)
    print "Decode 20K payload", timeit(
        lambda p=p,t=t: decodePayload(p, t).getUncompressedContents(), 1000)

    comp = "x"*(20*1024)
    p = encodeMessage(comp, 0, prng)[0]
    t = prng.getBytes(20)
    def decode(p=p,t=t):
        try:
            decodePayload(p,t).getUncompressedContents()
        except CompressedDataTooLong:
            pass
    print "Decode overcompressed payload", timeit(decode, 1000)
Exemple #2
0
 def decode(p=p,t=t):
     try:
         decodePayload(p,t).getUncompressedContents()
     except CompressedDataTooLong:
         pass