Tracking down superlinear reductions

Andrew Lentvorski bsder@REDACTED
Sat Jun 17 01:14:02 CEST 2006


Bengt Kleberg wrote:
> On 2006-06-16 12:13, Andrew Lentvorski wrote:
> ...deleted
>> What I'd like to do is the Erlang equivalent of getting the number of 
>> times a function is called.  This would avoid the problem of Erlang 
>> trying to print out the arguments and flooding the I/O system.
> 
> have a look at: cprof, eprof, fprof and friends, in the tools section of 
> the docuemntation.
> http://erlang.org/doc/doc-5.5/lib/tools-2.5/doc/html/index.html

cprof did it.

...
{699175,
  [{orddict,535312,
            [{{orddict,store,3},524697},
...

Ouch!  And that's only for 1000 packets.  That's the only function in my 
entire program that isn't within a small multiplier of 1000.  I'm not 
calling orddict:store() anywhere near that many times.

It looks like orddict:store() is an O(n) function as it seems to be 
doing a linear scan.  That explains why its about 1000*1000/2.  A linear 
scan should be O(n)/2.

I'll go look at the gb_trees module.

Thanks for the help,
-a



More information about the erlang-questions mailing list