Skip to content

Instantly share code, notes, and snippets.

@spockz
Created March 29, 2010 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spockz/348570 to your computer and use it in GitHub Desktop.
Save spockz/348570 to your computer and use it in GitHub Desktop.
renderPixel :: Int -> Int -> Int -> RayMaker -> World -> Colour Int
--
parMap rdeepseq
(\(i,j) -> renderPixel depth i j raymaker world)
[(i,j) | i <- [0..h-1], j <- [0..w-1]]
--
$> +RTS -N2 -s -RTS ... => 100% cpu usage;
----
map (\(i,j) -> renderPixel depth i j raymaker world)
[(i,j) | i <- [0..h-1], j <- [0..w-1]]
`using` parListChunk (w*h `div` 2) rdeepseq
--
$> +RTS -N2 -s -RTS ... => 100-150% cpu usage but slower.
----
data Colour a = Colour !(a, a, a) deriving (Eq, Ord, Show)
type Colours a = [Colour a]
instance NFData (Colour a) where
rnf (Colour (x,y,z)) = x `seq` y `seq` z `seq` ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment