[erlang-questions] map over bitstring
Fri Oct 22 13:16:41 CEST 2010
On 22 okt 2010, at 11.25, Morten Krogh wrote:
> To my enormous surprise, this program is about 7 times faster than the binary comprehension.
> 18> A = binary:copy(<<"a">>, 10000000).
> 10 MB, that is.
> 19> T1 = now(), B = << <<"b">> || <<Y>> <= A>>, T2 = now(), timer:now_diff(T2,T1).
Interpreted code !!! Put this code in a module and compile it, then try again.
> 22> f(T1), f(T2), f(B).
> 23> T1 = now(), B = zip2:map(fun(X) -> 98 end, A), T2 = now(), timer:now_diff(T2,T1).
I guess zip2 is compiled.
> (zip2 is my module name for this test)
> What is going on?
There is a big speed difference between interpreted code and compiled code.
"Have run Make so many times I dunno what's installed anymore"
More information about the erlang-questions