1
- from typing import Dict , Optional
1
+ import argparse
2
+ import gzip
2
3
import timeit
3
- from isal import igzip , isal_zlib
4
4
import zlib
5
- import gzip
6
5
from pathlib import Path
7
- import argparse
6
+ from typing import Dict
7
+
8
+ from isal import isal_zlib
8
9
9
- DATA_DIR = Path (__file__ ).parent / "tests" / "data"
10
+ DATA_DIR = Path (__file__ ).parent / "tests" / "data"
10
11
COMPRESSED_FILE = DATA_DIR / "test.fastq.gz"
11
12
with gzip .open (str (COMPRESSED_FILE ), mode = "rb" ) as file_h :
12
13
data = file_h .read ()
20
21
"16kb" : data [:16 * 1024 ],
21
22
"32kb" : data [:32 * 1024 ],
22
23
"64kb" : data [:64 * 1024 ],
23
- #"128kb": data[:128*1024],
24
- #"512kb": data[:512*1024]
24
+ # "128kb": data[:128*1024],
25
+ # "512kb": data[:512*1024]
25
26
}
26
27
compressed_sizes = {name : zlib .compress (data_block )
27
28
for name , data_block in sizes .items ()}
28
29
29
30
compressed_sizes_gzip = {name : gzip .compress (data_block )
30
31
for name , data_block in sizes .items ()}
31
32
33
+
32
34
def show_sizes ():
33
35
print ("zlib sizes" )
34
- print ("name\t " + "\t " .join (str (level ) for level in range (- 1 ,10 )))
36
+ print ("name\t " + "\t " .join (str (level ) for level in range (- 1 , 10 )))
35
37
for name , data_block in sizes .items ():
36
38
orig_size = max (len (data_block ), 1 )
37
39
rel_sizes = (
@@ -44,7 +46,8 @@ def show_sizes():
44
46
for name , data_block in sizes .items ():
45
47
orig_size = max (len (data_block ), 1 )
46
48
rel_sizes = (
47
- str (round (len (isal_zlib .compress (data_block , level )) / orig_size , 3 ))
49
+ str (round (len (isal_zlib .compress (data_block , level )) / orig_size ,
50
+ 3 ))
48
51
for level in range (0 , 4 ))
49
52
print (name + "\t " + "\t " .join (rel_sizes ))
50
53
@@ -69,6 +72,8 @@ def benchmark(name: str,
69
72
isal_nanosecs ,
70
73
zlib_nanosecs ,
71
74
ratio ))
75
+
76
+
72
77
# show_sizes()
73
78
74
79
def argument_parser () -> argparse .ArgumentParser :
@@ -79,6 +84,7 @@ def argument_parser() -> argparse.ArgumentParser:
79
84
parser .add_argument ("--gzip" , action = "store_true" )
80
85
return parser
81
86
87
+
82
88
if __name__ == "__main__" :
83
89
args = argument_parser ().parse_args ()
84
90
if args .checksums or args .all :
0 commit comments