forked from anoma/juvix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContext.hs
43 lines (40 loc) · 1.31 KB
/
Context.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module Context where
import qualified Criterion.Main as Criterion
import qualified Juvix.Backends.LLVM as LLVM
import qualified Juvix.Desugar as Desugar
import Juvix.Library hiding (mod)
import qualified Juvix.Library.Feedback as Feedback
import qualified Juvix.Parsing.Parser as Parser
import qualified Juvix.Pipeline as Pipeline
import qualified Juvix.Pipeline.ToSexp as ToSexp
import qualified Text.Megaparsec as P
bench :: Criterion.Benchmark
bench =
Criterion.bgroup
"desugar"
[guardTest]
guardTest :: Criterion.Benchmark
guardTest =
Criterion.env
( liftIO $
Feedback.runFeedbackT $
Pipeline.toML
LLVM.BLLVM
( ""
<> "mod Let where\n"
<> "open Prelude\n"
<> "sig (==) : field -> field -> bool\n"
<> "let (==) = %LLVM.eq\n"
<> "declare infixl (==) 2\n"
<> "let foo | x == 3 = 3 | else = 2"
)
)
( \ ~(Feedback.Success _ t) ->
Criterion.bgroup
"guardTest"
[ Criterion.bench "guard small WHNF" $
Criterion.whnfIO (either (panic . show) identity <$> ToSexp.contextify t),
Criterion.bench "guard small NF" $
Criterion.nfIO (either (panic . show) identity <$> ToSexp.contextify t)
]
)