Comparing the printing of Int64 and Int32 with Float64 and Float32, it seems that the former could be more efficient:
julia> @btime join(fill(1.0, 10^6), " ") evals=1 samples=1;
159.393 ms (28 allocations: 11.63 MiB)
julia> @btime join(fill(1, 10^6), " ") evals=1 samples=1;
151.988 ms (2000027 allocations: 101.18 MiB)
Despite the allocations, the integer case seems to be slightly faster. Why is this a problem?
I would expect printing integers to be quite a bit faster. Isn't it a simpler task?
For example, here's a comparison of the same operation with kdb+/q (a high performance APL-like language, timings are in milliseconds):
julia> @btime join(fill(1.0, 10^6)) evals=1 samples=1;
149.535 ms (28 allocations: 11.63 MiB)
julia> @btime join(fill(1, 10^6)) evals=1 samples=1;
131.836 ms (2000024 allocations: 100.18 MiB)
q)\t raze string 1000000#1.0
42
q)\t raze string 1000000#1
13
(I removed the space to simplify the example.)
Ok, thanks, it is helpful to have a point of comparison. In fact it looks like both operations should be faster.
1.2:
julia> @btime join(fill(1.0, 10^6), " ") evals=1 samples=1;
134.654 ms (1000027 allocations: 26.89 MiB)
julia> @btime join(fill(1, 10^6), " ") evals=1 samples=1;
103.964 ms (2000026 allocations: 101.18 MiB)
master
julia> @btime join(fill(1.0, 10^6), " ") evals=1 samples=1;
81.318 ms (2000027 allocations: 425.62 MiB)
julia> @btime join(fill(1, 10^6), " ") evals=1 samples=1;
58.768 ms (2000026 allocations: 101.18 MiB)
More allocations, faster speed :)
I assume Ryu make the Float printing faster, despite (or because) the extra allocations it does. What made Int printing faster?
Most helpful comment
Despite the allocations, the integer case seems to be slightly faster. Why is this a problem?