Beispiel #1
0
def check_packb(arg):
  packed = msgpackya.packb(arg)
  target = msgpack.packb(arg)
  if(target == packed):
    return True
  else:
    print("error: " + str(arg) +
          " expected:" + str(dump_byte(target)) +
          "\tactually:" + str(dump_byte(packed)))
    return False
Beispiel #2
0
def unpack_time(target, times):
  ya = org = None
  if(mode == "kya" or mode == "comp"):
    import msgpackya
    packed = msgpackya.packb(target)
    packya_unpackb = msgpackya.unpackb
    begin = time.time()
    for i in range(times):
      packya_unpackb(packed)
    ya = time.time() - begin

  if(mode == "orig" or mode == "comp"):
    import msgpack
    packed = msgpack.packb(target)
    pack_packb = msgpack.packb
    begin = time.time()
    for i in range(times):
      pack_packb(target)
    org = time.time() - begin
  if(mode == "comp"):
     return ("msgpackya :"+str(ya), "cython:"+str(org))
  return ya or org
Beispiel #3
0
def pack_check(num):
  print(str(num)+":"+dump_byte(msgpackya.packb(num)))