-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* The tasty stuff results in a more complicated eventlog, which is distracting. * Used `unsafe` rather than `safe` calls, to avoid GC interference. * Use only two capabilities. * Explore both `a+b` and `b+a` (slowAdd is slow in the _second_ arg)
- Loading branch information
Showing
3 changed files
with
17 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,19 @@ | ||
module Main (main) where | ||
|
||
import Control.Concurrent.Async (concurrently) | ||
import Test.Tasty | ||
import Test.Tasty.HUnit | ||
import Test.Tasty.Runners (NumThreads(..)) | ||
|
||
import Test.TraceForeignCalls.UsePlugin | ||
|
||
main :: IO () | ||
main = defaultMain $ localOption (NumThreads 1) $ | ||
testGroup "trace-foreign-calls" [ | ||
testCase "answerIO" $ do | ||
answer <- answerIO | ||
assertEqual "" 42 $ answer | ||
, testCase "answerPure" $ do | ||
let answer = answerPure | ||
assertEqual "" 42 $ answer | ||
, testCase "slowAddIO" $ do | ||
let a = 1_000_000_000 | ||
b = 2_000_000_000 | ||
result <- slowAddIO a b | ||
assertEqual "" (a + b) $ result | ||
, testCase "slowAddPure" $ do | ||
let a = 1_000_000_000 | ||
b = 2_000_000_000 | ||
let result = slowAddPure a b | ||
assertEqual "" (a + b) $ result | ||
, testCase "slowAddConcurrent" $ do | ||
let a = 1_000_000_000 | ||
b = 2_000_000_000 | ||
(ab, ba) <- concurrently (slowAddIO a b) (slowAddIO b a) | ||
assertEqual "" ab ba | ||
] | ||
main = do | ||
print =<< answerIO | ||
print $ answerPure | ||
print =<< slowAddIO a b | ||
print =<< slowAddIO b a | ||
print $ slowAddPure a b | ||
print $ slowAddPure b a | ||
print =<< concurrently (slowAddIO a b) (slowAddIO b a) | ||
print =<< concurrently (slowAddIO b a) (slowAddIO a b) | ||
where | ||
a = 1_000_000_000 | ||
b = 2_000_000_000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters