On Saturday, January 25, 2014 9:24:17 PM UTC+2, Jason Merrill wrote:
>
> mma> data = RandomReal[1.,1*^7]; min = .2; max = .3;
> mma> Total@Unitize@Clip[data,{min,max},{0,0}]
>
> I claim that it takes *a lot* of experience to know that that is the code
> that is going to be fast, compared to the other 15 approaches people bring
> up there, because the mapping between Mathematica's core constructs and the
> machine's core constructs is far more complicated and indirect than for
> Julia.
>
> In contrast, it doesn't take deep familiarity with Julia's standard
> library to come up with about the fastest way to write this operation.
>
> julia> function count_range(arr, min, max)
> count = 0
> for elt in arr
> if min < elt < max count += 1 end
> end
> count
> end
>
> It takes more than one line to write, but it's *obvious*. My Mathematica
> license is expired these days, so I can't run the benchmark, but I bet it
> also smokes the fast solution in Mathematica.
>
Having a Mathematica license and being curious I compared them. The Julia
version is roughly 10x faster than the Mathematica version.