on 17618de help sign in
elk/bench/src/Realistic/Check.elm
65 lines 1.0 kB history raw
1module Realistic.Check (benchmark) where
2{-| Source: http://elm-lang.org/examples/checkboxes
3-}
5import Benchmark
6import String
9benchmark : Benchmark.Benchmark
10benchmark =
11 Benchmark.suite "check box business logic"
12 [ run "toggle boxes" toggleActions
13 ]
16run : String -> List Action -> Benchmark.Benchmark
17run description actions =
18 Benchmark.test
19 (description ++ " - " ++ toString (List.length actions) ++ " actions")
20 (\_ -> List.foldl update initialModel actions)
23toggleActions =
24 [ Red True
25 , Underline True
26 , Bold True
27 , Bold False
28 , Red False
29 , Bold True
30 , Bold False
31 ]
34-- MODEL
36type alias Model =
37 { red : Bool
38 , underline : Bool
39 , bold : Bool
40 }
43initialModel =
44 Model False False True
47-- UPDATE
49type Action
50 = Red Bool
51 | Underline Bool
52 | Bold Bool
55update action model =
56 case action of
57 Red bool ->
58 { model | red = bool }
60 Underline bool ->
61 { model | underline = bool }
63 Bold bool ->
64 { model | bold = bool }