<br><div><span class="gmail_quote">2006/8/28, Ulf Wiger (TN/EAB) <<a href="mailto:ulf.wiger@ericsson.com">ulf.wiger@ericsson.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>I usually write a benchmark loop allowing me to measure over enough<br>iterations to bring the times into at least hundreds of milliseconds or<br>seconds. Then I repeat several times and take the lowest value (least<br>
amount of interference). Then (of course), I divide the time by the<br>number of iterations.<br><br>I also usually repeat the procedure with an empty loop, and calculate<br>the difference.<br><br>It's reasonable to spawn a new process for each iteration, to make sure
<br>that the measurement doesn't start with lots of garbage on the heap.<br><br>BR,<br>Ulf W<br><br>> -----Original Message-----<br>> From: <a href="mailto:owner-erlang-questions@erlang.org">owner-erlang-questions@erlang.org
</a><br>> [mailto:<a href="mailto:owner-erlang-questions@erlang.org">owner-erlang-questions@erlang.org</a>] On Behalf Of<br>> Matthew Sackman<br>> Sent: den 28 augusti 2006 10:06<br>> To: <a href="mailto:erlang-questions@erlang.org">
erlang-questions@erlang.org</a><br>> Subject: Re: Timer:tc<br>><br>> On Mon, Aug 28, 2006 at 11:52:26AM +0800, lang er wrote:<br>> > So why:<br>> > Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe]
<br>> ><br>> > Eshell V5.5  (abort with ^G)<br>> > 1> timer:tc(count_chars,file, ["gc.txt"]).<br>> > {1173,116}<br>><br>> File has to be fetched from harddisc, so will cost time.
<br>><br>> > 2> timer:tc(count_chars,file, ["gc.txt"]).<br>> > {375,116}<br>><br>> Now file is cached in RAM by OS so access is much faster.<br>><br>> > 3> T1 = erlang:now(),<br>
> > 3> count_chars:file("gc.txt"),<br>> > 3> T2 = erlang:now(),<br>> > 3> Time = timer:now_diff(T2, T1).<br>> > 464<br>><br>> Oh. Unknown - someone who knows Erlang much better than I
<br>> will have to answer that. OTOH, 464 isn't much higher than<br>> 375 - these are microseconds. My guess is that it's<br>> experimental variance - how repeatable are these numbers? Do<br>> it 10 times both methods, both orderings and average. For
<br>> most functions, the cost of the function itself will be much<br>> greater than the cost of the function invocation so the<br>> expense of the apply in :tc/3 won't feature for any function<br>> that does any "real" work(!)
<br>><br>> Matthew<br>> --<br>> Matthew Sackman<br>><br>> BOFH excuse #259:<br>> Someone's tie is caught in the printer, and if anything else<br>> gets printed, he'll be in it too.<br>><br></blockquote>
</div>Yes, certainly I should do like this.<br>Are there any facility like ruby's bm?<br>