[erlang-questions] surprise! binary vs list in file parse.
Thu Jun 26 16:39:38 CEST 2008
2008/6/26 litao cheng <>:
> I had read joel's article:Parsing text and binary files with Erlang. In the
> article, the author show how to parse a comma-delimited text file.
> I write the code for practice, the module source is act.erl. By the way, I
> see in the bottom of joel' article, a buddy give a comment, he says, he use
> binary to instead of some list, It seems so efficient, so I write the second
> code, it's act_2.erl.
> Finally, I want to test how much the act_2 faster than act. So suprise, In
> my Compute, The result is :
> 96> timer_avg:tc(act, parse, ["test.txt"], 100).
> Max: 15991
> Min: 1
> Avg: 2339.05
> 100> timer_avg:tc(act_2, parse, ["test.txt"], 100).
> Max: 15997
> Min: 1
> Avg: 4839.03
> the timer_avg is a moudule evaluates apply(Module, Function, Arguments) N
> times and measures the elapsed real time, about Max, Min, Avg. (use
> who will give me some explain?
You might want to retry the tests, starting them instead with
spawn(timer_avg, tc, [act, parse, ["test.txt"], 100]).
spawn(timer_avg, tc, [act_2, parse, ["test.txt"], 100]).
This way you don't get any random garbage collections to interfere.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions