[erlang-questions] Re: Best way to implement a simple cache

David Mercer dmercer@REDACTED
Fri Nov 13 15:13:54 CET 2009


Matt Stancliff wrote:

> While I have my benchmarking hat on, let's check function calls too:
> Call Method             ||  Multiplier  || Percent Slowdown || Calls
> Per Second
> =
> =
> =
> =
> =
> =
> =
> ========================================================================
> apply(?MODULE, foo, [])        1.00x            0%
> 96,089,747.8
> ?MODULE:foo()                  1.01x            1%
> 94,809,477.4
> foo()                          1.09x            9%
> 88,485,052.9
> fun() -> ok end()              3.15x          215%
> 30,489,431.6
> apply(foo, [])                 3.50x          250%
> 27,481,044.5
> Module:Fun()                   5.22x          422%
> 18,392,358.4

Is this a surprise to anyone else?  I myself would have expected foo() to be
the fastest, since it knows exactly which function to call, whereas the two
that rank above it have to look for the most recent version of foo/0.
Anyone have an explanation for this?




More information about the erlang-questions mailing list