[Haskell-cafe] using Map rather than FiniteMap

S. Alexander Jacobson alex at alexjacobson.com
Tue Jan 25 18:26:43 EST 2005

Oops.  It pays to check your checking code before 
making posts like this.

After actually running the correct test, I am 
still getting semi-ridiculous space behavior 

    import qualified Map
    zipped =zip [1..] [1..100000]::[(Int,Int)]
    untup f (x,y) = f x y
    produce = foldr (untup Map.insert) Map.empty zipped
    fm = length  $ Map.keys produce
    main = print $ fm

Has this profile:

 	   example +RTS -p -K5M -RTS

 	total time  =        5.10 secs   (255 ticks @ 20 ms)
 	total alloc = 612,534,236 bytes  (excludes profiling overheads)

    	COST CENTRE                    MODULE               %time %alloc
 	balance                        Map                   71.8   72.8
 	insert                         Map                   12.2   10.8
 	size                           Map                    9.0    9.7
 	bin                            Map                    2.4    2.2
 	rotateR                        Map                    1.6    0.3
 	zipped                         Main                   0.8    1.9

Notice the 612Mb for storing a mapping from Int 
to Int!!

Also 5M of stack is required to make this work.

Can anyone help?


S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com

On Tue, 25 Jan 2005, Jorge Adriano Aires wrote:

>> Just did a search after my last post and learned
>> that FiniteMap is bad.  Discoverd that Data.Map is
>> the intended replacement.  Downloaded it and
>> modified it to work with 6.2.  Blazingly fast!
>> Yay.
> Hi, just curious,
> How much trouble was getting it to work with ghc 6.2 and adapting your program
> to use the API of Data.Map instead of Data.FiniteMap?
> J.A.

More information about the Haskell-Cafe mailing list