I noticed the original motivation for using Formatting.jl was performance, with a 100x5 table of floats being called out specifically as a benchmark. Since Julia 1.6, Printf has a fast dynamic formatter, and it seems to outperform Formatting.jl. With the benchmark
julia> using PrettyTables, BenchmarkTools
julia> data = Any[ f(a) for a = 1:100, f in (sind, cosd, tand, sind, sind)];
julia> @btime sprint(io -> pretty_table(io, data; formatters = ft_printf("%5.3f")));
on this branch I see
667.000 μs (13377 allocations: 770.06 KiB)
whereas on master I see
19.551 ms (32369 allocations: 1.58 MiB)
Additionally, all tests pass as-is, showing the compatibility of the approaches - I believe that is because PrettyTables is using just sprintf1 which is meant to be like @sprintf. (As a quick check, I put in a println("hi") in the new sprintf1 function to ensure it really is being called, and I could see it indeed is).
closes https://github.com/ronisbr/PrettyTables.jl/issues/210
I noticed the original motivation for using Formatting.jl was performance, with a 100x5 table of floats being called out specifically as a benchmark. Since Julia 1.6, Printf has a fast dynamic formatter, and it seems to outperform Formatting.jl. With the benchmark
on this branch I see
whereas on master I see
Additionally, all tests pass as-is, showing the compatibility of the approaches - I believe that is because PrettyTables is using just
sprintf1
which is meant to be like@sprintf
. (As a quick check, I put in aprintln("hi")
in the newsprintf1
function to ensure it really is being called, and I could see it indeed is).