@@ -3,6 +3,13 @@ module Suite exposing (main)
3import Benchmark exposing (Benchmark)
3import Benchmark exposing (Benchmark)
4import Benchmark.Runner exposing (BenchmarkProgram, program)
4import Benchmark.Runner exposing (BenchmarkProgram, program)
6+import Element exposing (..)
7+import Element.Background as Background
8+import Element.Font as Font
10+import Html.Attributes
11+import Internal.Flag as Flag
12+import Internal.Model as Internal
6import Json.Encode
13import Json.Encode
@@ -23,11 +30,150 @@ main : BenchmarkProgram
24 program <|
31 program <|
25 Benchmark.describe "sample"
32 Benchmark.describe "sample"
27− , deduplications
34+ -- , deduplications
43+ Benchmark.describe "Flag Operations"
44+ [ Benchmark.benchmark "check if present" <|
46+ Flag.present Flag.height Flag.none
47+ , Benchmark.benchmark "add to flagt" <|
49+ Flag.add Flag.height Flag.none
54+ Benchmark.describe "Gathering Attributes"
55+ [ Benchmark.benchmark "existing - gatherAttrRecursive" <|
57+ Internal.gatherAttrRecursive
58+ (Internal.contextClasses Internal.AsEl)
61+ Internal.Untransformed
64+ Internal.NoNearbyChildren
65+ [ Element.width Element.shrink
66+ , Element.height Element.shrink
68+ , Benchmark.benchmark "Simple list filterMap" <|
75+ , Benchmark.benchmark "Simple list map" <|
82+ , Benchmark.benchmark "Foldl base speed" <|
89+ , Benchmark.benchmark "Recursive" <|
96+ , Benchmark.benchmark "foldl - new record each iteration" <|
99+ { attributes = "class"
102+ , children = Nothing
105+ -- we reverse first because we have to for the attr api.
108+ , Just "other width"
111+ , Benchmark.benchmark "foldl - update" <|
113+ List.foldl flipFoldlUpdate
114+ { attributes = "class"
117+ , children = Nothing
120+ -- we reverse first because we have to for the attr api.
123+ , Just "other width"
126+ , Benchmark.benchmark "String Concatenation" <|
136+ , Benchmark.benchmark "List String Concatenation" <|
151+flipFoldl result found =
152+ { attributes = "class" ++ found.attributes
153+ , styles = Just 1 :: found.styles
155+ , children = Nothing
156+ , has = Flag.add Flag.height found.has
160+flipFoldlUpdate result found =
162+ | attributes = "class" ++ found.attributes
163+ , styles = Just 1 :: found.styles
164+ , has = Flag.add Flag.height found.has
174+ fn fst (recurse fn remain)
31deduplications =
177deduplications =
32 Benchmark.describe "deduplications"
178 Benchmark.describe "deduplications"
33 [ Benchmark.benchmark "fold - dedup, String concat"
179 [ Benchmark.benchmark "fold - dedup, String concat"
@@ -96,3 +242,89 @@ largeListJson =
97 ( "elem-" ++ String.fromInt wrappingI, Json.Encode.string ("elem-" ++ String.fromInt wrappingI) )
243 ( "elem-" ++ String.fromInt wrappingI, Json.Encode.string ("elem-" ++ String.fromInt wrappingI) )
248+ [ Benchmark.benchmark "build 2000 elements"
250+ elements 0 twoThousand
252+ , Benchmark.benchmark "build 2000 html"
265+ (Element.column [ spacing 8, centerX ]
266+ (List.map (viewEl i) count)
270+viewEl selectedIndex index =
273+ (if selectedIndex == index then
280+ (if selectedIndex /= index then
290+ (if selectedIndex == index then
309+ (List.map (viewHtmlElement i) count)
313+viewHtmlElement selectedIndex index =
315+ [ Html.Attributes.class
316+ (if selectedIndex == index then
324+ [ if selectedIndex == index then
325+ Html.text "selected"