blacken all files.

This commit is contained in:
Inada Naoki 2019-12-05 18:53:49 +09:00
parent 10e5e39ff9
commit bc8c86203a
3 changed files with 159 additions and 144 deletions

View file

@ -1,6 +1,8 @@
from msgpack import fallback
try:
from msgpack import _unpacker, _packer
has_ext = True
except ImportError:
has_ext = False
@ -9,7 +11,7 @@ import timeit
def profile(name, func):
times = timeit.repeat(func, number=1000, repeat=4)
times = ', '.join(["%8f" % t for t in times])
times = ", ".join(["%8f" % t for t in times])
print("%-30s %40s" % (name, times))
@ -18,17 +20,19 @@ def simple(name, data):
packer = _packer.Packer()
profile("packing %s (ext)" % name, lambda: packer.pack(data))
packer = fallback.Packer()
profile('packing %s (fallback)' % name, lambda: packer.pack(data))
profile("packing %s (fallback)" % name, lambda: packer.pack(data))
data = packer.pack(data)
if has_ext:
profile('unpacking %s (ext)' % name, lambda: _unpacker.unpackb(data))
profile('unpacking %s (fallback)' % name, lambda: fallback.unpackb(data))
profile("unpacking %s (ext)" % name, lambda: _unpacker.unpackb(data))
profile("unpacking %s (fallback)" % name, lambda: fallback.unpackb(data))
def main():
simple("integers", [7]*10000)
simple("bytes", [b'x'*n for n in range(100)]*10)
simple("lists", [[]]*10000)
simple("dicts", [{}]*10000)
simple("integers", [7] * 10000)
simple("bytes", [b"x" * n for n in range(100)] * 10)
simple("lists", [[]] * 10000)
simple("dicts", [{}] * 10000)
main()