[Haskell-cafe] Re: FASTER primes
Will Ness
will_n48 at yahoo.com
Sat Jan 9 04:51:44 EST 2010
Daniel Fischer <daniel.is.fischer <at> web.de> writes:
>
>
> Am Donnerstag 07 Januar 2010 11:43:44 schrieb Heinrich Apfelmus:
> > Will Ness wrote:
> > > Heinrich Apfelmus writes:
>
> The below code is now a well-behaved memory citizen (3MB for the 100
millionth prime, about the same as the PQ code). It still is considerably
slower than the PQ code.
> In terms of MUT times as reported by +RTS -sstderr - as well as (MUT+GC)
times - (measured once for prime No. 5*10^5, 10^6, 2*10^6, 4*10^6, 10^7 to get
a rough tendency), it seems to scale a wee bit better than any of the other
tfold versions I created, but a little worse than the PQ versions.
> The relation of MUT times isn't too bad, but the GC times are rather abysmal
(30-40%).
>
> ----------------------------------------------------------------------
>
> data People a = P { vips :: [a], dorks :: [a] }
>
> celebrate x p = P (x:vips p) (dorks p)
>
> mergeSP p1@(P a _) p2 = P (a ++ vips mrgd) (dorks mrgd)
> where
> mrgd = spMerge (dorks p1) (vips p2) (dorks p2)
> spMerge l1 [] l3 = P [] (merge l1 l3)
> spMerge ~l1@(x:xs) l2@(y:ys) l3 = case compare x y of
> LT -> celebrate x (spMerge xs l2 l3)
> EQ -> celebrate x (spMerge xs ys l3)
> GT -> celebrate y (spMerge l1 ys l3)
>
I forgot to say something *very* important. :) Here it is.
Yippee-hurray!
:)
More information about the Haskell-Cafe
mailing list