From 9997d2fdf9855325a32f3d69d1d482060aa31c77 Mon Sep 17 00:00:00 2001 From: roflmaostc Date: Tue, 16 Nov 2021 14:07:17 -0500 Subject: [PATCH] Add another binning [skip ci] --- examples/benchmarks/bin.jl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/benchmarks/bin.jl b/examples/benchmarks/bin.jl index b4bb501..e58593b 100644 --- a/examples/benchmarks/bin.jl +++ b/examples/benchmarks/bin.jl @@ -1,11 +1,25 @@ using BenchmarkTools, MicroscopyTools +function bin_3(arr::AbstractArray{T, N}, factors=ntuple(x -> 2, Val(N))) where {T, N} + # old size + sz = size(arr) + # new size + sn = sz .รท factors + s2 = ntuple(i -> isodd(i) ? factors[(i+1)/2] : sn[i/2], Val(2 * N)) + + dims = ntuple(i -> 2 * i - 1, Val(N)) + reshape(sum(reshape(arr,s2),dims=dims),sn) +end + + function f(x) @info "Random data with size $(size(x))" print("Tullio: ") @btime bin2($x) print("CartesianIndices: ") @btime bin($x, (2,2)) + print("RH: ") + @btime bin_3($x, (2,2)) end function main()