diff options
author | Inada Naoki <songofacandy@gmail.com> | 2019-12-05 18:53:49 +0900 |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2019-12-05 18:53:49 +0900 |
commit | bc8c86203af8d36152c9c72ea22e895db2ed3fe0 (patch) | |
tree | 2a6ff59476dbaf5d6b2de0aea63d49c5ba102cf9 /benchmark | |
parent | 10e5e39ff9739fa3ce589ad9d451260be0f3842c (diff) | |
download | msgpack-python-bc8c86203af8d36152c9c72ea22e895db2ed3fe0.tar.gz |
blacken all files.
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/benchmark.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 80819c6..82d0ddb 100644 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -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() |