25 ms·
Take the code here: https://github.com/logicchains/levgen-benchmarks/blob/master/H.hs https://github.com/logicchains/levgen-benchmarks/blob/master... and run it
by logicchains 13y ago
Take the code here: https://github.com/logicchains/levgen-benchmarks/blob/master/H.hs https://github.com/logicchains/levgen-benchmarks/blob/master... and run it. Then, take the same code, change the genRooms function to contain:
where
noFit = genRooms (n-1) (restInts) rsDone
tr = Room {rPos=(x,y), rw= w, rh= h}
x = rem (U.unsafeHead randInts) levDim
y = rem (U.unsafeIndex randInts 1) levDim
restInts = U.unsafeDrop 4 randInts
w = rem (U.unsafeIndex randInts 2) maxWid + minWid
h = rem (U.unsafeIndex randInts 3) maxWid + minWid
And change:
let rands = U.unfoldrN 10000000 (Just . next) gen
to:
let rands = U.unfoldrN 20000000 (Just . next) gen
The running time should double. Does it? Or does it increase by orders of magnitude? The latter is what happens to me.
- cgag 13y agoI just changed the random number bit, not the 10000000 part, and it took ~100x longer. No idea why.
- logicchains 13y agoMaybe a compiler bug?
- cgag 13y agoI'm a total noob to haskell and I'm not sure I understand the code well enough to ask an intelligent question about it, but I'd love to see you/someone ask on the haskell mailing list/stackoverflow/reddit-haskell or something.
- logicchains 13y agoI'll post a question on Stack Overflow then when I have time.