What if BinCounts is not fast enough? It looks like BinCounts could be optimized a bit more, at least in the specific situation when the bin boundaries are fixed and the bin widths are equal.
In[1]:= d = RandomReal[1, 5*^6];
In[2]:= BinCounts[d, {0, 1, 0.1}] // AbsoluteTiming
Out[2]= {4.816101, {500339, 500068, 500609, 500186, 499183, 498943, 499839, 500473, 500514, 499846}}
HistogramList performs differently (faster or slower … )
Here’s a trick to do this an order of magnitude faster:
In[3]:= SortBy[Tally@Floor[d, 0.1], First][[All, 2]] // AbsoluteTiming
Out[3]= {0.586790, {500339, 500068, 500609, 500186, 499183, 498943, 499839, 500473, 500514, 499846}}
The performance difference depends on the bin size (as Tally slows down when it needs to count more types of items).
I hope that this will be useful for someone. Comments are welcome, especially since the Tally version still isn’t fast enough for my needs.