-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.hs
23 lines (20 loc) · 1003 Bytes
/
stats.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import System.Process
roundN :: Int -> Double -> Double
roundN n a = (fromIntegral $ round $ a*(10^n))/(10^n)
main = do
stats <- mapM statsForRun [(min, lots) | min <- [2..6],lots <- [2..6]]
let rounded = map (roundN 3) stats
putStrLn $ show stats
putStrLn $ show rounded
writeFile "rawstats" $ show rounded
statsForRun :: (Int, Int) -> IO Double
statsForRun (min, lots) = do
writeFile "values.h" $ "int MIN_FREE = " ++ show min ++ "; int LOTS_FREE = " ++ show lots ++ ";\n"
runCommand "make -B" >>= waitForProcess
runCommand "./OSP par/par.high" >>= waitForProcess
runCommand "grep \"number of pagefaults\" simulation.run|awk '{print $12}' > faults.tmp" >>= waitForProcess
runCommand "grep \"references\" simulation.run|awk '{print $7}' > refs.tmp" >>= waitForProcess
faults <- readFile "faults.tmp" >>= return . sum . map read . lines
refs <- readFile "refs.tmp" >>= return . sum . map read . lines
putStrLn $ show $ (faults, refs, faults / refs)
return $ faults / refs