Skip to content

Instantly share code, notes, and snippets.

View spockz's full-sized avatar

Alessandro Vermeulen spockz

View GitHub Profile
$> cat > foo.hs
{-# RULES "foo/Integer" foo = intFoo #-}
foo :: Num a => a -> a -> a
foo = (+)
intFoo = (-)
main = (putStrLn . show) ((foo (1::Integer) (1::Integer))::Integer)
$> ghc --make -O -ddump-rules -ddump-simpl-stats foo.hs
module Main where
import Control.Parallel
import Control.Parallel.Strategies
foo = map (id) [1..10000] `using` parListChunk 400 rdeepseq
type Square = Square' Nil
data Square' t a = Zero (t (t a)) | Succ (Square' (Cons t) a)
data Nil a = Nil deriving Show
data Cons t a = Cons a (t a) deriving Show
mapNil :: (a -> b) -> Nil a -> Nil b
mapNil _ _ = Nil
mapCons :: ((a -> b) -> (t a -> t b))
-> (a -> b)
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;
----
pixels = concat
[[renderPixel depth i j raymaker world | i <- [0..(h `div` 2 - 1)], j <- [0..w-1]] `using` parListChunk (w*h `div` 4) rdeepseq
,[renderPixel depth i j raymaker world | i <- [(h `div` 2)..h-1], j <- [0..w-1]]] `using` parListChunk (w*h `div` 4) rdeepseq
`using` parListChunk (w*h `div` 4) rdeepseq
solveQuadratic :: Double -> Double -> Double -> Intersections
solveQuadratic a b c =
case compare discr 0.0 of
LT -> []
EQ -> [-b / (2 * a)]
GT -> [abc (-), abc (+)]
where discr = b ^ 2 - 4 * a * c
abc op = (-b `op` sqrt discr) / (2 * a)
-- vs
Thu Apr 1 18:31 2010 Time and Allocation Profiling Report (Final)
raytrace +RTS -P -hc -RTS tests/Input/gml/references/testall.gml
total time = 175.26 secs (8763 ticks @ 20 ms)
total alloc = 34,673,331,808 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc ticks bytes
intervals'_ayp1 Base.Shape.Cylinder 22.0 17.9 1926 1552298191
Fri Apr 2 22:59 2010 Time and Allocation Profiling Report (Final)
raytrace +RTS -P -hc -RTS tests/Input/gml/references/testall.gml
total time = 133.14 secs (6657 ticks @ 20 ms)
total alloc = 34,741,677,700 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc ticks bytes
intervals'_ayaN Base.Shape.Cylinder 19.7 17.9 1313 1552298191
data Zero = Zero
data Succ a = Succ a
class Times x y z | x y -> z where
times :: x -> y -> z
instance Times Zero x Zero where
times Zero x = Zero
instance (Times n x r', Add x r' r) => Times (Succ n) x r where
DSN: pgsql://klantenlogin:*password with a dot*@unix(/var/run/postgresql)/bink_klantenlogin_ng
->
doctrine-version: 1.2.2
error:
PDO Connection Error: SQLSTATE[08006] [7] could not translate host name "unix(" to address: Name or service not known