[erlang-questions] erlang:md5/1 vs crypto:md5/1 difference: speed

Lev Walkin vlm@REDACTED
Sat Jan 31 11:28:19 CET 2009


Scott Lystig Fritchie wrote:
> Hi, all.  Two years ago, Roberta Saccon asked a question of the
> difference between erlang:md5/1 vs crypto:md5/1.
> 
> One answer was, "none."  Another answer was, "You need to start the
> crypto application before calling crypto:md5/1."
> 
> I've discovered a third answer: speed.  On a newer Intel Xeon single
> CPU, dual-core box @ 2.33GHz, and on an AMD X2 single CPU, dual-core
> box, crypto:md5/1 is 3.0-3.5 times faster on a 64KByte blob than
> erlang:md5.  On an older 3.4GHz single core Xeon, the difference is over
> almost 7x, and on a several-year-old Pentium M laptop @ 1.33GHz, the
> difference is 8x.(*)
> 
> I'm curious ... do others see similar differences?  Or is erlang:md5/1
> faster on some platforms, e.g. PowerPC?

On PowerPC G4 (1.5 GHz) the difference is up to 10x in favor of 
crypto:md5/1. However, it seem to vary greatly depending on the input size.

The following chart summarizes the findings.

Blob size	erlang:md5	crypto:md5	winner
(bytes)		(ops/seconds)	(ops/second)

34		132778		98205		erlang ~35% faster
63		122425		92851		erlang
65		121247		93296		erlang
80		119739		93464		erlang
90		112531		92757		erlang
95		118074		94302		erlang
100		120783		99943		erlang ~28% faster
101		64845		97556		crypto ~51% faster
102		63076		93717		crypto
103		64369		95260		crypto
104		63359		92948		crypto
105		63638		95318		crypto
110		64147		98937		crypto
120		63961		92614		crypto
161		61173		94997		crypto ~55% faster
204		41394		92266		crypto ~120% faster
49242		304		2627		crypto ~750% faster
499242		29		265		crypto ~800% faster
4999242		~3		23		crypto


So it appears that erlang:md5/1 is up to 35% faster on data less than 
100 bytes long, and crypto:md5/1 is up to 10x faster asymptotically.


-- 
Lev Walkin
vlm@REDACTED



More information about the erlang-questions mailing list