Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-10 Thread Vasyl Pasternak
Hi all, To summarize everything in this thread I've tested mwc-random, System.Random and mersenne random numbers (mersenne-random-pure64). Here the score table: [THIRD PLACE] Generic Random Number Generator. Is the slowest and allocates too much memory in the heap. The total memory usage is const

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Felipe Lessa
On Tue, Feb 09, 2010 at 04:27:57PM -0800, Bryan O'Sullivan wrote: > It creates and returns a vector, so if you ask it to give you a billion > items, it's going to require north of 8 gigabytes of memory. This should not > come as a surprise, I'd hope :-) Assuming that's not what you actually > want

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Bryan O'Sullivan
On Tue, Feb 9, 2010 at 3:48 PM, Vasyl Pasternak wrote: > > mwc-random is really fast. But it eats to much memory. It creates and returns a vector, so if you ask it to give you a billion items, it's going to require north of 8 gigabytes of memory. This should not come as a surprise, I'd hope :-)

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Vasyl Pasternak
Bryan, mwc-random is really fast. But it eats to much memory. My previous attempts were to reduce total number of allocations. This package made this possible, but it increases total memory usage. Here is the code: import Text.Printf import System.Random.MWC import Control.Applicative import Sys

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Vasyl Pasternak
Daniel, Yes, I have 64 bit system. Maybe you're right. The PRNG code with the same vector size allocates two times more memory at my PC. (~ 1 Gb) Thank you, Vasyl 2010/2/9 Daniel Fischer : > Am Tuesday 09 February 2010 19:19:18 schrieben Sie: >> Daniel, >> >> I've just run venum2 program locall

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Daniel Fischer
Am Dienstag 09 Februar 2010 19:27:58 schrieb Bryan O'Sullivan: > On Tue, Feb 9, 2010 at 4:18 AM, Vasyl Pasternak > > wrote: > > I tried to generate memory-efficient list of random numbers, so I've > > used uvector library for this task. > > Use the mwc-random package. It provides a function that do

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Daniel Fischer
Am Tuesday 09 February 2010 19:19:18 schrieben Sie: > Daniel, > > I've just run venum2 program locally and here is my results: > > $ ./venum2 1000 +RTS -s > ./venum2 1000 +RTS -s > 500500 > 22,736 bytes allocated in the heap > 688 bytes copied during GC >

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Bryan O'Sullivan
On Tue, Feb 9, 2010 at 4:18 AM, Vasyl Pasternak wrote: > > I tried to generate memory-efficient list of random numbers, so I've > used uvector library for this task. Use the mwc-random package. It provides a function that does exactly this, and produces better quality random numbers with much hi

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Daniel Fischer
Am Tuesday 09 February 2010 15:43:13 schrieben Sie: > Update: > > I've implemented `enumFromToU` through `unfoldU`: > > enumFromToU' from to = unfoldU (to - from) f from > >where f i = let i' = i + 1 in JustS (i' :*: i') > > This code behaves similarly to `enumFromToU` (i.e. constantly uses ~25

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Daniel Fischer
Am Dienstag 09 Februar 2010 14:51:31 schrieb Vasyl Pasternak: > Sorry, maybe I should ask more clearer. > > I've looked at dons article "Haskell as fast as C"[1], and tried to > implement similar algorithm but for list of random numbers. > > Please look at code: > > import Text.Printf > > import Co

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Vasyl Pasternak
Sorry, maybe I should ask more clearer. I've looked at dons article "Haskell as fast as C"[1], and tried to implement similar algorithm but for list of random numbers. Please look at code: > import Text.Printf > import Control.Applicative > import System.Environment > import Data.Array.Vector >

Re: [Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Daniel Fischer
Am Dienstag 09 Februar 2010 13:18:23 schrieb Vasyl Pasternak: > Hello Cafe, > > I tried to generate memory-efficient list of random numbers, so I've > used uvector library for this task. But it doesn't work, > it still allocates more than 6Gb of memory for the random list of 10 > > million elements

[Haskell-cafe] Generate random UArray in constant memory space.

2010-02-09 Thread Vasyl Pasternak
Hello Cafe, I tried to generate memory-efficient list of random numbers, so I've used uvector library for this task. But it doesn't work, it still allocates more than 6Gb of memory for the random list of 10 million elements. Here is the code: > import Text.Printf > import System.Random > import C