Minor refactoring of the tests

parent c5b5bd5e
...@@ -4,8 +4,9 @@ module Bench( -- sequential benchmarks ...@@ -4,8 +4,9 @@ module Bench( -- sequential benchmarks
, par , par
-- distributed benhcmarks -- distributed benhcmarks
, dist , dist
-- miscellaneous
, main , main
, sz , getAnswer
) where ) where
import Control.Distributed.Process import Control.Distributed.Process
...@@ -21,10 +22,16 @@ import Utils ...@@ -21,10 +22,16 @@ import Utils
type Result = ([Vertex], [MasterStats]) type Result = ([Vertex], [MasterStats])
--type Result = String --type Result = String
-- | Gets the result of the calculation
result :: ([Vertex], [MasterStats]) -> Result result :: ([Vertex], [MasterStats]) -> Result
result = id result = id
--result = sz . snd --result = sz . snd
-- | Gets the size (as a string) from the result
getAnswer :: Result -> String
getAnswer = sz . snd
--getAnswer = id
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- benchmarks, parametrised by -- benchmarks, parametrised by
-- * list of Generators -- * list of Generators
......
...@@ -13,7 +13,7 @@ import Test.Framework.Providers.HUnit (testCase) ...@@ -13,7 +13,7 @@ import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit (Assertion) import Test.HUnit (Assertion)
import Test.HUnit.Base (assertBool) import Test.HUnit.Base (assertBool)
import Bench (seq, par, dist, sz) import Bench (seq, par, dist, getAnswer)
import MasterWorker (__remoteTable) import MasterWorker (__remoteTable)
import Utils import Utils
...@@ -22,81 +22,81 @@ import Utils ...@@ -22,81 +22,81 @@ import Utils
testSeqShort :: TestResult String -> Process () testSeqShort :: TestResult String -> Process ()
testSeqShort result = do testSeqShort result = do
x <- seq gg13 11 x <- seq gg13 11
stash result (getRes x) stash result (getAnswer x)
testSeqIntermediate :: TestResult String -> Process () testSeqIntermediate :: TestResult String -> Process ()
testSeqIntermediate result = do testSeqIntermediate result = do
x <- seq gg124 157 x <- seq gg124 157
stash result (getRes x) stash result (getAnswer x)
testSeqLong :: TestResult String -> Process () testSeqLong :: TestResult String -> Process ()
testSeqLong result = do testSeqLong result = do
x <- seq gg1245 157 x <- seq gg1245 157
stash result (getRes x) stash result (getAnswer x)
-- Parallel Tests -- Parallel Tests
testParShort :: TestResult String -> Process () testParShort :: TestResult String -> Process ()
testParShort result = do testParShort result = do
x <- par True gg13 11 2 x <- par True gg13 11 2
stash result (getRes x) stash result (getAnswer x)
testParIntermediate :: TestResult String -> Process () testParIntermediate :: TestResult String -> Process ()
testParIntermediate result = do testParIntermediate result = do
x <- par True gg124 157 2 x <- par True gg124 157 2
stash result (getRes x) stash result (getAnswer x)
testParLong :: TestResult String -> Process () testParLong :: TestResult String -> Process ()
testParLong result = do testParLong result = do
x <- par True gg1245 157 2 x <- par True gg1245 157 2
stash result (getRes x) stash result (getAnswer x)
testParSeqShort :: TestResult String -> Process () testParSeqShort :: TestResult String -> Process ()
testParSeqShort result = do testParSeqShort result = do
x <- par False gg13 11 2 x <- par False gg13 11 2
stash result (getRes x) stash result (getAnswer x)
testParSeqIntermediate :: TestResult String -> Process () testParSeqIntermediate :: TestResult String -> Process ()
testParSeqIntermediate result = do testParSeqIntermediate result = do
x <- par False gg124 157 2 x <- par False gg124 157 2
stash result (getRes x) stash result (getAnswer x)
testParSeqLong :: TestResult String -> Process () testParSeqLong :: TestResult String -> Process ()
testParSeqLong result = do testParSeqLong result = do
x <- par False gg1245 157 2 x <- par False gg1245 157 2
stash result (getRes x) stash result (getAnswer x)
-- Distributed Tests -- Distributed Tests
testDistShort :: [NodeId] -> TestResult String -> Process () testDistShort :: [NodeId] -> TestResult String -> Process ()
testDistShort nodes result = do testDistShort nodes result = do
x <- dist True gg13 11 2 nodes x <- dist True gg13 11 2 nodes
stash result (getRes x) stash result (getAnswer x)
testDistIntermediate :: [NodeId] -> TestResult String -> Process () testDistIntermediate :: [NodeId] -> TestResult String -> Process ()
testDistIntermediate nodes result = do testDistIntermediate nodes result = do
x <- dist True gg124 157 2 nodes x <- dist True gg124 157 2 nodes
stash result (getRes x) stash result (getAnswer x)
testDistLong :: [NodeId] -> TestResult String -> Process () testDistLong :: [NodeId] -> TestResult String -> Process ()
testDistLong nodes result = do testDistLong nodes result = do
x <- dist True gg1245 157 2 nodes x <- dist True gg1245 157 2 nodes
stash result (getRes x) stash result (getAnswer x)
testDistSeqShort :: [NodeId] -> TestResult String -> Process () testDistSeqShort :: [NodeId] -> TestResult String -> Process ()
testDistSeqShort nodes result = do testDistSeqShort nodes result = do
x <- dist False gg13 11 2 nodes x <- dist False gg13 11 2 nodes
stash result (getRes x) stash result (getAnswer x)
testDistSeqIntermediate :: [NodeId] -> TestResult String -> Process () testDistSeqIntermediate :: [NodeId] -> TestResult String -> Process ()
testDistSeqIntermediate nodes result = do testDistSeqIntermediate nodes result = do
x <- dist False gg124 157 2 nodes x <- dist False gg124 157 2 nodes
stash result (getRes x) stash result (getAnswer x)
testDistSeqLong :: [NodeId] -> TestResult String -> Process () testDistSeqLong :: [NodeId] -> TestResult String -> Process ()
testDistSeqLong nodes result = do testDistSeqLong nodes result = do
x <- dist False gg1245 157 2 nodes x <- dist False gg1245 157 2 nodes
stash result (getRes x) stash result (getAnswer x)
-- Batch the tests -- Batch the tests
...@@ -165,10 +165,6 @@ main = testMain $ orbitTests ...@@ -165,10 +165,6 @@ main = testMain $ orbitTests
-- Auxiliary functions -- Auxiliary functions
------------------------------------------------------------------- -------------------------------------------------------------------
-- | Gets the size from MasterStats.
getRes = Result -> String
getRes = sz . snd
-- | A mutable cell containing a test result. -- | A mutable cell containing a test result.
type TestResult a = MVar a type TestResult a = MVar a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment