Pattern matching vs. ETS lookups

Serge Aleynikov <>
Tue Feb 17 13:37:56 CET 2004


Thank you Vance!  I couldn't have excpected a better response.  :-)

Serge

Vance Shipley wrote:

> Curiosity got the better of me so I ran some benchmarks.
> 
> The attached runs four different versions a gen_server.
> The first test is with a full 65K of {module, function}
> tuples of generated atoms.  Each test is a loop of 1000
> gen_server:call.
> 
>                         CNT       ACC         OWN
> list                   14605, 2874.423, 11382.772
> gb_trees               14632,  163.546,   578.699
> ets                    14631,  148.579,   523.257
> tuple of tuples        14632,  146.690,   512.442
> 
> 
> This is the output of fprof:analyse.  Obviously the 
> list version is not effecient.  The others seem 
> equivalent.
> 
> With only 3000 random entries:
> 
> list                   14647,  221.448,   814.819
> gb_trees               14648,  154.442,   551.877
> ets                    14648,  155.908,   558.271
> 
> 
> The list implentation isn't so bad now.  There 
> doesn't seem to be much difference in the others.
> I'm now satisfied that my gb_trees method is just
> as effecient as an ets table.
> 
> 	-Vance





More information about the erlang-questions mailing list