S. Alexander Jacobson wrote:
   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

I get similar results without optimizations and much better ones using only about 160MB with -O.


Cheers Christian

-- unoptimized
           testMap +RTS -p -K5m -RTS

        total time  =        6.34 secs   (317 ticks @ 20 ms)
        total alloc = 612,549,684 bytes  (excludes profiling overheads)

COST CENTRE                    MODULE               %time %alloc

balance                        Common.Lib.Map        74.1   72.8
insert                         Common.Lib.Map         9.8   10.8
size                           Common.Lib.Map         9.5    9.7
bin                            Common.Lib.Map         1.6    2.2
zipped                         Main                   1.3    1.9

-- optimized results
ghc --make TestMap.hs -O -prof -auto-all  -o testMap

           testMap +RTS -p -K5m -RTS

        total time  =        1.22 secs   (61 ticks @ 20 ms)
        total alloc = 159,737,668 bytes  (excludes profiling overheads)

COST CENTRE                    MODULE               %time %alloc

insert                         Common.Lib.Map        39.3    0.5
balance                        Common.Lib.Map        24.6   47.4
size                           Common.Lib.Map        21.3   34.1
foldR                          Common.Lib.Map         3.3    2.5
zipped                         Main                   3.3    6.5
untup                          Main                   3.3    0.8
produce                        Main                   3.3    0.8
singleR                        Common.Lib.Map         1.6    0.0
toAscList                      Common.Lib.Map         0.0    1.5
single                         Common.Lib.Map         0.0    1.5
keys                           Common.Lib.Map         0.0    1.5
bin                            Common.Lib.Map         0.0    3.0
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to