[prev in list] [next in list] [prev in thread] [next in thread]
List: haskell-cafe
Subject: Re: [Haskell-cafe] using Map rather than FiniteMap
From: "S. Alexander Jacobson" <alex () alexjacobson ! com>
Date: 2005-01-26 17:21:20
Message-ID: Pine.WNT.4.61.0501261146250.2544 () philo
[Download RAW message or body]
On Tue, 25 Jan 2005, David Menendez wrote:
> Does having 'zipped' at the top level mean that the program is keeping
> the entire 100,000-element list in memory?
I don't know, but I tested with zipped at the top,
in the where, and it appears to make no
performance or memory difference.
> Also, would performance improve if you used Map.fromList? How about
> Map.fromAscList?
HUGE IMPROVEMENT. The old code had maximum
residency of 11Mb and running time of 41s. The
code using Map.fromList has max. residency of
6.4Mb and running time of 5.2s!
I guess foldlStrict is HUGELY more efficient than
than foldr. (Why isn't it in the prelude?) But
even using foldrStrict (fromList), we are still
using 60 bytes per item and have ~30 bytes
unaccounted for. Any hints?
import qualified Map
main = print $ length $ Map.keys theMap
where
zipped =zip [1..] [1..100000]::[(Int,Int)]
theMap = Map.fromList zipped
-Alex-
______________________________________________________________
S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
> S. Alexander Jacobson writes:
>
>> After actually running the correct test, I am
>> still getting semi-ridiculous space behavior
>> (6k/pair)!
>>
>> 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
>
> Two questions I'm currently too lazy to investigate myself:
>
> --
> David Menendez <zednenem@psualum.com> | "In this house, we obey the laws
> <http://www.eyrie.org/~zednenem> | of thermodynamics!"
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic