Exemplo n.º 1
0
 def _cbGotUpdate(self, newState):
     self.__dict__.update(newState)
     self.isActivated = 1
     # send out notifications
     for listener in self._activationListeners:
         listener(self)
     self._activationListeners = []
     self.activated()
     with open(self.getFileName(), "wb") as dataFile:
         dataFile.write(banana.encode(jelly.jelly(self)))
Exemplo n.º 2
0
def jellyRoundTrip(testCase, toSerialize):
    """
    Verify that the given object round-trips through jelly & banana and comes
    out equivalent to the input.
    """
    jellied = jelly.jelly(toSerialize)
    encoded = banana.encode(jellied)
    decoded = banana.decode(encoded)
    unjellied = jelly.unjelly(decoded)
    testCase.assertEqual(toSerialize, unjellied)
 def _cbGotUpdate(self, newState):
     self.__dict__.update(newState)
     self.isActivated = 1
     # send out notifications
     for listener in self._activationListeners:
         listener(self)
     self._activationListeners = []
     self.activated()
     with open(self.getFileName(), "wb") as dataFile:
         dataFile.write(banana.encode(jelly.jelly(self)))
Exemplo n.º 4
0
 def send(self, data):
     toSend = zlib.compress(banana.encode(data),4)
     self.transport.write(toSend, self.address)
     NetworkServer.debugSendPacketLength = len(toSend)
Exemplo n.º 5
0
 def send(self, obj):
     data = zlib.compress(banana.encode(obj),1)
     self.transport.write(data)
     self.debugSendPacketLength = len(data)
Exemplo n.º 6
0
def a(var):
    t = timer()


    
    t.start(); data = banana.encode(var); t.stop()
    print "Enc B       :", t.time(), len(data)
    t.start(); banana.decode(data); t.stop()
    print "Dec B       :", t.time()
    t.start(); data = compress(banana.encode(var),9); t.stop()
    print "Enc B (zip9):", t.time(), len(data)
    t.start(); banana.decode(decompress(data)); t.stop()
    print "Dec B (zip9):", t.time()
    t.start(); data = compress(banana.encode(var),4); t.stop()
    print "Enc B (zip4):", t.time(), len(data)
    t.start(); banana.decode(decompress(data)); t.stop()
    print "Dec B (zip4):", t.time()
    t.start(); data = compress(banana.encode(var),1); t.stop()
    print "Enc B (zip1):", t.time(), len(data)
    t.start(); banana.decode(decompress(data)); t.stop()
    print "Dec B (zip1):", t.time()


    
    t.start(); data = cerealizer.dumps(var); t.stop()
    print "Enc C       :", t.time(), len(data)
    t.start(); cerealizer.loads(data); t.stop()
    print "Dec C       :", t.time()
    t.start(); data = compress(cerealizer.dumps(var),9); t.stop()
    print "Enc C (zip9):", t.time(), len(data)
    t.start(); cerealizer.loads(decompress(data)); t.stop()
    print "Dec C (zip9):", t.time()
    t.start(); data = compress(cerealizer.dumps(var),4); t.stop()
    print "Enc C (zip4):", t.time(), len(data)
    t.start(); cerealizer.loads(decompress(data)); t.stop()
    print "Dec C (zip4):", t.time()
    t.start(); data = compress(cerealizer.dumps(var),1); t.stop()
    print "Enc C (zip1):", t.time(), len(data)
    t.start(); cerealizer.loads(decompress(data)); t.stop()
    print "Dec C (zip1):", t.time()


    
    t.start(); data = Flatten.serialize(var); t.stop()
    print "Enc F       :", t.time(), len(data)
    t.start(); Flatten.unserialize(data); t.stop()
    print "Dec F       :", t.time()
    t.start(); data = compress(Flatten.serialize(var),9); t.stop()
    print "Enc F (zip9):", t.time(), len(data)
    t.start(); Flatten.unserialize(decompress(data)); t.stop()
    print "Dec F (zip9):", t.time()
    t.start(); data = compress(Flatten.serialize(var),4); t.stop()
    print "Enc F (zip4):", t.time(), len(data)
    t.start(); Flatten.unserialize(decompress(data)); t.stop()
    print "Dec F (zip4):", t.time()
    t.start(); data = compress(Flatten.serialize(var),1); t.stop()
    print "Enc F (zip1):", t.time(), len(data)
    t.start(); Flatten.unserialize(decompress(data)); t.stop()
    print "Dec F (zip1):", t.time()


    
    t.start(); data = banana.encode(jelly.jelly(var)); t.stop()
    print "Enc BJ      :", t.time(), len(data)
    t.start(); jelly.unjelly(banana.decode(data)); t.stop()
    print "Dec BJ      :", t.time()
    t.start(); data = compress(banana.encode(jelly.jelly(var)),9); t.stop()
    print "Enc BJ(zip9):", t.time(), len(data)
    t.start(); jelly.unjelly(banana.decode(decompress(data))); t.stop()
    print "Dec BJ(zip9):", t.time()
    t.start(); data = compress(banana.encode(jelly.jelly(var)),4); t.stop()
    print "Enc BJ(zip4):", t.time(), len(data)
    t.start(); jelly.unjelly(banana.decode(decompress(data))); t.stop()
    print "Dec BJ(zip4):", t.time()
    t.start(); data = compress(banana.encode(jelly.jelly(var)),1); t.stop()
    print "Enc BJ(zip1):", t.time(), len(data)
    t.start(); jelly.unjelly(banana.decode(decompress(data))); t.stop()
    print "Dec BJ(zip1):", t.time()