Skip to content

Commit 4ba2b36

Browse files
committed
Add extra benchmarks
1 parent 30d85fd commit 4ba2b36

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

benchmark.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import argparse
22
import gzip
3+
import io # noqa: F401 used in timeit strings
34
import timeit
45
import zlib
56
from pathlib import Path
@@ -82,6 +83,8 @@ def argument_parser() -> argparse.ArgumentParser:
8283
parser.add_argument("--checksums", action="store_true")
8384
parser.add_argument("--functions", action="store_true")
8485
parser.add_argument("--gzip", action="store_true")
86+
parser.add_argument("--sizes", action="store_true")
87+
parser.add_argument("--objects", action="store_true")
8588
return parser
8689

8790

@@ -112,3 +115,18 @@ def argument_parser() -> argparse.ArgumentParser:
112115
benchmark("gzip decompression", compressed_sizes_gzip,
113116
"igzip.decompress(data_block)",
114117
"gzip.decompress(data_block)")
118+
if args.objects or args.all:
119+
benchmark("zlib Compress instantiation", {"": b""},
120+
"a = isal_zlib.compressobj()",
121+
"a = zlib.compressobj()")
122+
benchmark("zlib Decompress instantiation", {"": b""},
123+
"a = isal_zlib.decompressobj()",
124+
"a = zlib.decompressobj()")
125+
benchmark("Gzip Writer instantiation", {"": b""},
126+
"a = igzip.GzipFile(fileobj=io.BytesIO(), mode='wb' )",
127+
"a = gzip.GzipFile(fileobj=io.BytesIO(), mode='wb')")
128+
benchmark("Gzip Reader instantiation", {"": b""},
129+
"a = igzip.GzipFile(fileobj=io.BytesIO(), mode='rb' )",
130+
"a = gzip.GzipFile(fileobj=io.BytesIO(), mode='rb')")
131+
if args.sizes or args.all:
132+
show_sizes()

0 commit comments

Comments
 (0)