-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathbench_read.R
More file actions
68 lines (60 loc) · 1.78 KB
/
bench_read.R
File metadata and controls
68 lines (60 loc) · 1.78 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# =============================================================================
# Benchmark suite: read_h5ad
# =============================================================================
# Benchmarks reading H5AD files into InMemoryAnnData and HDF5AnnData
# across different X matrix types.
# =============================================================================
bench_read <- function(h5ad_paths, iterations, x_types, zarr_paths) {
results <- list()
for (xt in x_types) {
path <- h5ad_paths[[xt]]
# Read → InMemoryAnnData
results <- c(
results,
run_one_benchmark(
name = paste0("read_InMemory_", xt),
expr = quote(read_h5ad(.path, as = "InMemoryAnnData")),
setup = bquote(.path <- .(path)),
iterations = iterations
)
)
# Read → HDF5AnnData
results <- c(
results,
run_one_benchmark(
name = paste0("read_HDF5_", xt),
expr = quote({
ad <- read_h5ad(.path, as = "HDF5AnnData")
ad$close()
}),
setup = bquote(.path <- .(path)),
iterations = iterations
)
)
}
# Read from Zarr store
for (xt in x_types) {
path <- zarr_paths[[xt]]
# Read Zarr → InMemoryAnnData
results <- c(
results,
run_one_benchmark(
name = paste0("read_zarr_InMemory_", xt),
expr = quote(read_zarr(.path, as = "InMemoryAnnData")),
setup = bquote(.path <- .(path)),
iterations = iterations
)
)
# Open Zarr lazily → ZarrAnnData
results <- c(
results,
run_one_benchmark(
name = paste0("read_zarr_Zarr_", xt),
expr = quote(read_zarr(.path, as = "ZarrAnnData")),
setup = bquote(.path <- .(path)),
iterations = iterations
)
)
}
results
}