[erlang-questions] surprise! binary vs list in file parse.

litao cheng litaocheng@REDACTED
Thu Jun 26 16:28:24 CEST 2008


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
timer:tc/3).

who will give me some explain?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080626/21a6d578/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: act.erl
Type: application/octet-stream
Size: 914 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080626/21a6d578/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: act_2.erl
Type: application/octet-stream
Size: 798 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080626/21a6d578/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: timer_avg.erl
Type: application/octet-stream
Size: 489 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080626/21a6d578/attachment-0002.obj>


More information about the erlang-questions mailing list