JuliaPlots / RecipesPipeline.jl

Utilities for processing recipes
http://juliaplots.org/RecipesPipeline.jl/dev/
MIT License
17 stars 17 forks source link

Fix `unzip` for empty vectors #110

Closed t-bltg closed 2 years ago

t-bltg commented 2 years ago

Fix https://github.com/JuliaPlots/Plots.jl/issues/4146.

performance

using BenchmarkTools

unzip1(v) = tuple((([t[j] for t in v]) for j in 1:length(v[1]))...)
unzip2(v) = map(x->getfield.(v, x), fieldnames(eltype(v)))

main() = begin
  a = [Tuple(rand(3)) for _ ∈ 1:1_000_000]
  @btime unzip1($a)
  @btime unzip2($a)
end

main()

output

  41.424 ms (6 allocations: 22.89 MiB)
  37.375 ms (6 allocations: 22.89 MiB)

We need more unit tests in RecipesPipeline.jl !

nightly failure is unrelated.