You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

module Main where
import System.Environment
import ThreadPoolTimed
import ThreadPoolTimed2
initialVector :: [Int]
initialVector = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
main :: IO ()
main = do args <- getArgs
let sec = read (args !! 0) :: Int
let rep = read (args !! 1) :: Int
let cores = read (args !! 2) :: Int
let evalf = (applyNtimes rep applyFun)
putStrLn "\n\n"
res2 <- threadPoolTimed cores sec evalf initialVector
putStrLn $ "ThreadPool result: " ++ (show $ sum res2) ++ " \n"
res1 <- threadPoolTimed2 sec evalf initialVector
putStrLn $ "ThreadPool2 result: " ++ (show $ sum res1) ++ " \n"
--res3 <- parallelizedTimed2 sec evalf initialVector
--putStrLn $ "ParMap result: " ++ (show $ sum res3) ++ " \n"
applyNtimes :: Int -> (a -> a) -> a -> a
applyNtimes 0 _ accum = accum
applyNtimes n f accum = applyNtimes (n - 1) f (f accum)
applyFun :: Int -> Int
applyFun x = x + 1