-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzarrs_python_benchmark_roundtrip.py
executable file
·44 lines (34 loc) · 1.14 KB
/
zarrs_python_benchmark_roundtrip.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
#!/usr/bin/env python3
import timeit
import click
import zarr
from zarr.storage import LocalStore, RemoteStore
import zarrs
zarr.config.set({
"threading.num_workers": None,
"array.write_empty_chunks": False,
"codec_pipeline": {
"path": "zarrs.ZarrsCodecPipeline",
"validate_checksums": True,
"store_empty_chunks": False,
"chunk_concurrent_minimum": 4,
"chunk_concurrent_maximum": None,
}
})
@click.command()
@click.argument('path', type=str)
@click.argument('output', type=str)
def main(path, output):
if path.startswith("http"):
store = RemoteStore(url=path) # broken with zarr-python 3.0.0a0
else:
store = LocalStore(path)
dataset = zarr.open(store=store, mode='r')
dataset_out = zarr.create(store=LocalStore(output), mode='w', shape=dataset.shape, chunks=dataset.chunks, dtype=dataset.dtype, codecs=dataset.metadata.codecs)
start_time = timeit.default_timer()
dataset_out[:] = dataset[:]
elapsed = timeit.default_timer() - start_time
elapsed_ms = elapsed * 1000.0
print(f"Round trip in {elapsed_ms:.2f}ms")
if __name__ == "__main__":
main()