Output compute time in laplace
authorRoman Leshchinskiy <rl@cse.unsw.edu.au>
Wed, 31 Mar 2010 01:42:33 +0000 (01:42 +0000)
committerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Wed, 31 Mar 2010 01:42:33 +0000 (01:42 +0000)
examples/regularArrays/examples/laplace/Main.hs

index a122d6b..a0b8979 100644 (file)
@@ -12,6 +12,8 @@ import Data.List                              as L
 import Data.Maybe
 import System.Environment
 
+import Bench.Benchmark ( time, showTime )
+
 import PPM
 import ColorRamp
 
@@ -105,11 +107,19 @@ laplace solver steps fileInput fileOutput
                        <- readPPMAsMatrix2 loadPixel fileInput
 
        let matInitial  = matBoundValue
-       let matFinal    = solver
+
+        matBoundMask
+          `deepSeqArray` matBoundValue
+          `deepSeqArray` return ()
+
+        (matFinal, t) <- time
+                       $ let matFinal  = solver
                                steps
                                matBoundMask 
                                matBoundValue 
                                matInitial
+                         in
+                         matFinal `deepSeqArray` return matFinal
 
        -- Write out the matrix as a colorised PPM image        
        writeMatrixAsNormalisedPPM
@@ -117,6 +127,8 @@ laplace solver steps fileInput fileOutput
                (rampColorHotToCold 0.0 1.0)
                matFinal
 
+        putStrLn (showTime t)
+
 
 loadPixel :: Int -> Int -> Int -> (Double, Double)
 loadPixel r g b