<div dir="ltr">Did you test if returned values from global:whereis_name  is correct? You should do it especially when you don't believe benchmark result. You should check return value from each function call if you want trust your code. It can catch big amount of weird errors.<br>
<br><div class="gmail_quote">On Thu, Oct 9, 2008 at 1:14 PM, Joel Reymont <span dir="ltr"><<a href="mailto:joelr1@gmail.com">joelr1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
%%% and finally, the moment you have all been waiting for!<br>
%%% ...<br>
%%% registered names<br>
<br>
-module(map7).<br>
<div class="Ih2E3d">-behaviour(gen_server).<br>
<br>
-export([init/1, handle_call/3, handle_cast/2,<br>
         handle_info/2, terminate/2, code_change/3]).<br>
<br>
</div>-export([start/1, test/1, populate/1, lookup/1]).<br>
<br>
start(N) -><br>
     gen_server:start({global, N}, map7, [], []).<br>
<div class="Ih2E3d"><br>
init([]) -><br>
     {ok, none}.<br>
<br>
terminate(_, _) -><br>
     ok.<br>
<br>
</div><div class="Ih2E3d">handle_cast(stop, Data) -><br>
     {stop, normal, Data}.<br>
<br>
</div>handle_call(Event, From, Data) -><br>
<div class="Ih2E3d">     error_logger:info_report([{module, ?MODULE},<br>
                              {line, ?LINE},<br>
                              {self, self()},<br>
</div>                               {event, Event},<br>
                               {from, From}<br>
                              ]),<br>
     {noreply, Data}.<br>
<div class="Ih2E3d"><br>
handle_info(Info, Data) -><br>
     error_logger:info_report([{module, ?MODULE},<br>
                              {line, ?LINE},<br>
                              {self, self()},<br>
                              {message, Info}]),<br>
     {noreply, Data}.<br>
<br>
code_change(_, Data, _) -><br>
     {ok, Data}.<br>
<br>
test(N) -><br>
</div>     {T1, _} = timer:tc(map7, populate, [N]),<br>
     {T2, _} = timer:tc(map7, lookup, [N]),<br>
<div class="Ih2E3d">     io:format("Populate: ~.4. f~n", [T1 / 1000000]),<br>
     io:format("Lookup:   ~.4. f~n", [T2 / 1000000]),<br>
</div>     stop(N).<br>
<br>
populate(0) -><br>
     ok;<br>
<br>
populate(N) -><br>
     {ok, _} = start(N),<br>
     populate(N - 1).<br>
<br>
lookup(0) -><br>
     ok;<br>
<br>
lookup(N) -><br>
     P = global:whereis_name(N),<br>
     lookup(N - 1).<br>
<br>
stop(0) -><br>
     ok;<br>
<br>
stop(N) -><br>
     gen_server:cast({global, N}, stop),<br>
     stop(N - 1).<br>
<div><div></div><div class="Wj3C7c"><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil<br>
</div>