Skip to content

Commit bd35af7

Browse files
committed
Add zst fileslice benchmark
1 parent b0c23fb commit bd35af7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

nibabel/benchmarks/bench_fileslice.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
from ..rstutils import rst_table
2020
from ..tmpdirs import InTemporaryDirectory
2121

22+
try:
23+
import pyzstd
24+
ZSTD_INSTALLED = True
25+
except ImportError:
26+
ZSTD_INSTALLED = False
27+
2228
SHAPE = (64, 64, 32, 100)
2329
ROW_NAMES = [f'axis {i}, len {dim}' for i, dim in enumerate(SHAPE)]
2430
COL_NAMES = ['mid int',
@@ -70,7 +76,8 @@ def g():
7076
def bench_fileslice(bytes=True,
7177
file_=True,
7278
gz=True,
73-
bz2=False):
79+
bz2=False,
80+
zst=True):
7481
sys.stdout.flush()
7582
repeat = 2
7683

@@ -103,4 +110,11 @@ def my_table(title, times, base):
103110
my_table('bz2 slice - raw (ratio)',
104111
np.dstack((bz2_times, bz2_times / bz2_base)),
105112
bz2_base)
113+
if ZSTD_INSTALLED:
114+
if zst:
115+
with InTemporaryDirectory():
116+
zst_times, zst_base = run_slices('data.zst', repeat)
117+
my_table('zst slice - raw (ratio)',
118+
np.dstack((zst_times, zst_times / zst_base)),
119+
zst_base)
106120
sys.stdout.flush()

0 commit comments

Comments
 (0)