Closed Moelf closed 3 years ago
Since Julia defaults to Int for offsets, it might be better to just convert - should be very fast, and it's just a single mem alloc.
but it is known to be faster to use smaller types in any tight loop. I mean it allocates to do a convert
julia> a = rand(Int32, 200);
julia> function f(ary)
for _ = 1:100
convert(Vector{Float64}, ary)
end
nothing
end
f (generic function with 1 method)
julia> @benchmark f($a)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 8.464 μs … 560.591 μs ┊ GC (min … max): 0.00% … 93.67%
Time (median): 12.672 μs ┊ GC (median): 0.00%
Time (mean ± σ): 15.314 μs ± 21.938 μs ┊ GC (mean ± σ): 7.61% ± 5.62%
▁▄▅▇█▃ ▂
██████▇█▆▇█▄▄▃▄▄▅▅▅▅▃▄▄▄▃▅▅▅▄▃▃▄▄▃▃▄▁▁▃▁▁▁▁▁▁▁▁▁▁▁▅▅▆▆▇▇█▇██ █
8.46 μs Histogram: log(frequency) by time 70.4 μs <
Memory estimate: 176.56 KiB, allocs estimate: 100.
We have to have Int32 vectors, as I said, ROOT forces it, I don't see why we shouldn't support it, if not default to it.
Hm, yes, let's support Int32
then (withInt
as default). May come in handy if the data type is Float32
or Bool
.
ROOT uses Int32 for all (jagg) offsets internally, everywhere.