Skip to content

Instantly share code, notes, and snippets.

@ndevenish
Created March 25, 2021 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndevenish/bf03b390adddb33089a8c6a70e8f4936 to your computer and use it in GitHub Desktop.
Save ndevenish/bf03b390adddb33089a8c6a70e8f4936 to your computer and use it in GitHub Desktop.
Script from Graeme to test HDF5 plugin performance
import h5py
import bitshuffle.h5 # other plugins could be loaded instead
import sys
import time
def reader(filename):
"""Read the data in filename, as an exercise for the CPU."""
t0 = time.time()
with h5py.File(filename, "r") as f:
d = f["/entry/data/data"]
frames, slow, fast = d.shape
for frame in range(frames):
image = d[frame, :, :]
t1 = time.time()
print(f"Total: {t1 - t0} Per-frame: {(t1 - t0) / frames}")
if __name__ == "__main__":
reader(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment