comparison test/ParWrite.hs @ 16:72cc49b616cd

print in rpar
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Wed, 22 Jan 2014 15:23:36 +0900
parents 3337ccc824a4
children 8d4e37c1a86a
comparison
equal deleted inserted replaced
15:3337ccc824a4 16:72cc49b616cd
44 44
45 t0 <- getCurrentTime 45 t0 <- getCurrentTime
46 printTimeSince t0 46 printTimeSince t0
47 47
48 sequence_ $ runEval $ dualWrite jungle 48 sequence_ $ runEval $ dualWrite jungle
49 tree1 <- getRootNode jungle treeId
50 tree2 <- getRootNode jungle treeId2
51
52 print $ fromJust (getAttributes tree1 lastPos (show (writeCount-1)))
53 print $ fromJust (getAttributes tree2 lastPos (show (writeCount-1)))
54 49
55 printTimeSince t0 50 printTimeSince t0
56 51
57 -- parallel write for two trees by singleWrite 52 -- parallel write for two trees by singleWrite
58 dualWrite jungle = do 53 dualWrite jungle = do
59 x <- rpar (updateRootNodeWith (writeFunctions writeCount) jungle treeId) 54 x <- rpar (test jungle treeId)
60 y <- rseq (updateRootNodeWith (writeFunctions writeCount) jungle treeId2) 55 y <- rpar (test jungle treeId2)
61 rseq x
62 return [x, y] 56 return [x, y]
57
58 test jungle id = do
59 updateRootNodeWith (writeFunctions writeCount) jungle id
60 tree <- getRootNode jungle id
61 print $ fromJust (getAttributes tree lastPos (show (writeCount-1)))
63 62
64 -- generate functions to node update 63 -- generate functions to node update
65 writeFunctions :: Int -> Node -> Node 64 writeFunctions :: Int -> Node -> Node
66 writeFunctions writeCount node = foldl' apply node [0..writeCount] 65 writeFunctions writeCount node = foldl' apply node [0..writeCount]
67 where 66 where