Permalink
Browse files

Ported

  • Loading branch information...
1 parent 0bc94c3 commit 29ba0cb3ae9168f4bac3373c66b1af437cff8392 @aleator committed Feb 13, 2012
Showing with 19 additions and 11 deletions.
  1. +2 −1 CV/Iterators.hs
  2. +17 −10 performance/Iterators.hs
View
@@ -1,4 +1,5 @@
-{-#LANGUAGE TypeFamilies, TypeSynonymInstances, ParallelListComp#-}
+{-#LANGUAGE TypeFamilies, TypeSynonymInstances, ParallelListComp,
+ FlexibleContexts, FlexibleInstances #-}
module CV.Iterators
( ImageContext(..)
, F32I
View
@@ -1,5 +1,5 @@
module Main where
-import Criterion.Main
+import Criterion.Main
import CV.Image
import qualified CV.ImageMath as IM
import System.IO.Unsafe
@@ -9,9 +9,15 @@ import CV.Iterators
import Data.List
import Data.Function
import qualified CV.Transforms as T
+import Data.Array.Repa
+
+repaMax img = foldAllP min (100) $
+ fromFunction (Z :. w :. h)
+ (\(Z :. x :. y) -> getPixel (x,y) img)
+ where (w,h) = getSize img
main = do
- Just x <- loadImage "smallLena.jpg"
+ Just x <- loadImage "smallLena.jpg"
let iter n = length $ filterPixels (>n) x
slow n = length $ filterPixelsSlow (>n) x
comp n = length $ [((i,j),p) | i<- [0..w-1] , j <- [0..h-1], let p = getPixel (i,j) x, p>n]
@@ -23,23 +29,24 @@ main = do
print (iter 0.5,slow 0.5, comp 0.5)
defaultMain [
bgroup "iterator" [
- bench "huge" $ nf iter 0.3
- ,bench "medium" $ nf iter 0.8
+ bench "huge" $ nf iter 0.3
+ ,bench "medium" $ nf iter 0.8
,bench "small" $ nf iter 0.9
-
+
,bgroup "list-comp" [
- bench "huge" $ nf comp 0.3
- ,bench "medium" $ nf comp 0.8
+ bench "huge" $ nf comp 0.3
+ ,bench "medium" $ nf comp 0.8
,bench "small" $ nf comp 0.9
,bgroup "Max-values" [
- bench "list" $ nf max1 x
+ bench "list" $ nf max1 x
+ ,bench "repa" $ nf repaMax x
,bench "c" $ nf max2 x
]
]
,bgroup "filter-pixels-slow" [
- bench "huge" $ nf comp 0.3
- ,bench "medium" $ nf comp 0.8
+ bench "huge" $ nf comp 0.3
+ ,bench "medium" $ nf comp 0.8
,bench "small" $ nf comp 0.9
]

0 comments on commit 29ba0cb

Please sign in to comment.