On Apr 15, 2010, at 15:34 , Denys Rtveliashvili wrote:
As for the performance of "alloca", I though it would be faster than "malloc". However, in a simple test I have just written it is actually slower. The test allocates 16-bytes arrays and immediately de-allocates them. This operation is repeated 1000000000 times. On my computer the C program takes 27 seconds to complete while Haskell version takes about 41.


Your C program is doing nothing but adjusting linked lists after the first time the block is allocated. free() puts the block at the head of a linked list of free blocks, and malloc() will find it there, unlink and return it.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to