[Haskell-cafe] poor performance when generating random text

2012-10-17 Thread Dmitry Vyal
Hello anyone I've written a snippet which generates a file full of random strings. When compiled with -O2 on ghc-7.6, the generation speed is about 2Mb per second which is on par with interpreted php. That's the fact I find rather disappointing. Maybe I've missed something trivial? Any

Re: [Haskell-cafe] poor performance when generating random text

2012-10-17 Thread Gregory Collins
System.Random is very slow. Try the mwc-random package from Hackage. On Wed, Oct 17, 2012 at 9:07 AM, Dmitry Vyal akam...@gmail.com wrote: Hello anyone I've written a snippet which generates a file full of random strings. When compiled with -O2 on ghc-7.6, the generation speed is about 2Mb

Re: [Haskell-cafe] poor performance when generating random text

2012-10-17 Thread Alfredo Di Napoli
What about this? I've tested on my pc and seems pretty fast. The trick is to generate the gen only once. Not sure if the inlines helps, though: import qualified Data.Text as T import System.Random.MWC import Control.Monad import System.IO import Data.ByteString as B import Data.Word (Word8)

Re: [Haskell-cafe] poor performance when generating random text

2012-10-17 Thread Dmitry Vyal
On 10/17/2012 12:45 PM, Alfredo Di Napoli wrote: What about this? I've tested on my pc and seems pretty fast. The trick is to generate the gen only once. Not sure if the inlines helps, though: What about this? I've tested on my pc and seems pretty fast. The trick is to generate the gen

Re: [Haskell-cafe] poor performance when generating random text

2012-10-17 Thread Alfredo Di Napoli
Glad to have been helpful :) Bests, Alfredo Sent from my iPad On 17/ott/2012, at 21:10, Dmitry Vyal akam...@gmail.com wrote: On 10/17/2012 12:45 PM, Alfredo Di Napoli wrote: What about this? I've tested on my pc and seems pretty fast. The trick is to generate the gen only once. Not sure if