forked from bendichter/zarr-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompress_normal.py
44 lines (33 loc) · 956 Bytes
/
compress_normal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
import timeit
import numpy as np
import line_profiler
import zarr
from zarr import blosc
if __name__ == "__main__":
sys.path.insert(0, '..')
# setup
a = np.random.normal(2000, 1000, size=200000000).astype('u2')
z = zarr.empty_like(a, chunks=1000000,
compression='blosc',
compression_opts=dict(cname='lz4', clevel=5, shuffle=2))
print(z)
print('*' * 79)
# time
t = timeit.repeat('z[:] = a', repeat=10, number=1, globals=globals())
print(t)
print(min(t))
print(z)
# profile
profile = line_profiler.LineProfiler(blosc.compress)
profile.run('z[:] = a')
profile.print_stats()
print('*' * 79)
# time
t = timeit.repeat('z[:]', repeat=10, number=1, globals=globals())
print(t)
print(min(t))
# profile
profile = line_profiler.LineProfiler(blosc.decompress)
profile.run('z[:]')
profile.print_stats()