In case this ends up being a common request for folks coming from Matlab, I added a histcountindices function to NaNStatistics in response to this post which should do what you want (just ] up to make sure you have the latest version). This should still be quite fast:
julia> using NaNStatistics, BenchmarkTools
julia> A = 10*rand(1000);
julia> N, bin = histcountindices(A, 0:1:10)
([110, 84, 90, 99, 95, 106, 94, 114, 112, 96], [4, 3, 8, 8, 8, 6, 4, 5, 5, 3 … 6, 2, 9, 5, 2, 9, 10, 2, 7, 3])
julia> @benchmark histcountindices($A, 0:1:10)
BenchmarkTools.Trial: 10000 samples with 7 evaluations.
Range (min … max): 4.111 μs … 1.156 ms ┊ GC (min … max): 0.00% … 99.27%
Time (median): 4.864 μs ┊ GC (median): 0.00%
Time (mean ± σ): 6.841 μs ± 33.029 μs ┊ GC (mean ± σ): 14.65% ± 3.13%
▁ ▃█
▂▄█▅███▄▄▃▃▃▃▂▂▃▃▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
4.11 μs Histogram: frequency by time 11.8 μs <
Memory estimate: 8.17 KiB, allocs estimate: 5.
c.f.
julia> using StatsBase
julia> @benchmark (h = fit(Histogram, $A, 0:1:10); searchsortedlast.(Ref(h.edges[1]), $A))
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 28.723 μs … 996.657 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 30.665 μs ┊ GC (median): 0.00%
Time (mean ± σ): 34.875 μs ± 18.328 μs ┊ GC (mean ± σ): 0.00% ± 0.00%
▇█▅▃▅▃▄▂ ▆▃ ▅▂▁▂ ▁ ▄▄ ▃▁ ▂
████████████▇▆▆██████▇███▇▆▇▆▆▅▆▅▅▆█▅▅▅▅▄▄▅▄▄▅▄▄▄▂▄▂▄▅▄██▇▅▅ █
28.7 μs Histogram: log(frequency) by time 65.5 μs <
Memory estimate: 8.14 KiB, allocs estimate: 3.