@@ -1,165 +0,0 @@
1−import Graphics.Element exposing (show)
4−import Task exposing (Task, andThen)
11−import LargeDictionary
16−import SmallRecordBench
18−import SmallTupleBench
21−import PatternMatchBench
28−{-| Compile this with --output=Benchmarks.html to generate
29− a webpage, which runs the benchmarks and shows the results.
34− Benchmark.Suite "My Suite"
35− [ Benchmark.bench1 "Access 20-field record 200 times: " RecordBench.sumRandomElems indices200
36− , Benchmark.bench1 "Access 9-field record 200 times: " SmallRecordBench.sumRandomElems indices200
38− , Benchmark.bench1 "Access 9-field tuple 200 times: " TupleBench.sumRandomElems indices200
39− , Benchmark.bench1 "Access 3-field tuple 200 times: " SmallTupleBench.sumRandomElems indices200
41− , Benchmark.bench1 "Access 20-constructor Type 200 times: " CtorBench.sumFieldsList ctorData200
42− , Benchmark.bench1 "Access 10-constructor Type 200 times: " SmallCtorBench.sumFieldsList smallCtorData200
44− , Benchmark.bench1 "Tail-recursive if function, called 200 times: " IfBench.tailRecSum indices200
45− , Benchmark.bench1 "If expression with 20 branches, called 200 times: " IfBench.manyConditionalSum indices200
46− , Benchmark.bench1 "If expression with 4 branches, called 200 times: " IfBench.fewConditionalSum indices200
48− , Benchmark.bench1 "Pattern match 18-levels deep, use all values, 200 times " PatternMatchBench.deepMatchSum nestedData200
49− , Benchmark.bench1 "Pattern match 18-levels deep, 16 wildcards, 200 times " PatternMatchBench.wildcardMatchSum nestedData200
50− , Benchmark.bench1 "Pattern match 4-levels deep, use all values, 200 times " PatternMatchBench.shallowMatchSum nestedData200
52− , Benchmark.bench1 "Make and sum dict, 10000 elems: " LargeDictionary.addNToDictAndSum 10000
53− , Benchmark.bench1 "Make and sum dict, 50 elems: " LargeDictionary.addNToDictAndSum 50
55− , Benchmark.bench1 "Array native foldr, 500 elems: " ArrayBench.foldrMeanStddev array500
56− , Benchmark.bench1 "Array native foldl, 500 elems: " ArrayBench.foldlMeanStddev array500
57− , Benchmark.bench1 "Array custom foldr, 500 elems: " ArrayBench.customFoldrMeanStddev array500
58− , Benchmark.bench1 "Array custom foldl, 500 elems: " ArrayBench.customFoldrMeanStddev array500
59− , Benchmark.bench3 "Array square nth elem, 500 elems: " ArrayBench.updateNRandomIndices (\x -> x*x) indices200 array500
61− , Benchmark.bench1 "Dict native foldr, 500 elems: " DictBench.foldrMeanStddev dict500
62− , Benchmark.bench1 "Dict native foldl, 500 elems: " DictBench.foldlMeanStddev dict500
63− , Benchmark.bench3 "Dict square nth elem, 500 elems: " DictBench.updateNRandomIndices (\x -> x*x) indices200 dict500
65− , Benchmark.bench1 "List native foldr, 500 elems: " ListBench.foldrMeanStddev list500
66− , Benchmark.bench1 "List native foldl, 500 elems: " ListBench.foldlMeanStddev list500
67− , Benchmark.bench1 "List custom foldr, 500 elems: " ListBench.customFoldrMeanStddev list500
68− , Benchmark.bench1 "List custom foldl, 500 elems: " ListBench.customFoldrMeanStddev list500
69− , Benchmark.bench3 "List square nth elem, 500 elems: " ListBench.updateNRandomIndices (\x -> x*x) indices200 list500
71− , Benchmark.bench2 "200 lookups in array of 500 elems: " ArrayBench.randomLookups indices200 (Array.fromList [1 .. 500] )
72− , Benchmark.bench2 "200 lookups in list of 500 elems: " ListBench.randomLookups indices200 ([1 .. 500] )
73− , Benchmark.bench2 "200 lookups in dict of 500 elems: " DictBench.randomLookups indices200 (Dict.fromList (List.map2 (,) [1 .. 500] [1 .. 500]) )
75− , Benchmark.bench1 "30s simulated animation @ 30fps: " AnimateBench.runAnimation timeSteps30s
76− , Benchmark.bench1 "TodoMVC: approx. 330 simulated actions " TodoBench.evalActions TodoBench.testActions
82−--Mailbox updated with benchmark run progress
83−results : Signal.Mailbox String
85− Signal.mailbox "Benchmark loading"
88−--The actual task which runs the benchmarks
89−port benchResults : (Task Benchmark.Never ())
91− Benchmark.runWithProgress (Just results) mySuite
92− `andThen` \_ -> Task.sleep 0
97− Signal.map (Graphics.Element.leftAligned << Text.fromString) results.signal
101−-- Random generation and structures
103−--Maximum size for random numbers
107−--Random generator for floating point numbers
109− Random.float (-1 * maxSize) (maxSize)
112−--Generate random indices for lists out of 500 elements
114− Random.int (0) (499)
117−--Random seeds: they're fixed, so it's not truly random
118−--But we get seemingly random data, that we can compare fairly
119−--across multiple runs of the benchmark
121−--seed for our index generation
123− Random.initialSeed 56
126−--Seed for our float generation
128− Random.initialSeed 23
131−--Pseudo-random array of 500 floating point numbers
133− (ArrayBench.randomArray floatGen 500 seed)
136−--Pseudo-random dictionary, indexed 0 .. 500, of 500 floating point numbers
138− (DictBench.randomDict floatGen 500 seed)
142−--Same contents as array500, but in list form
144− (ListBench.randomList floatGen 500 seed)
147−--Pseudo random list of 200 indices between 0 and 499
149− (ListBench.randomList indexGen 200 indexSeed)
152−--List of timesteps simulating 30 seconds of animation at 30fps
154− List.map (\x -> (1.0 / 30.0) * (toFloat x * Time.second) ) [1 .. 900]
157− List.map CtorBench.makeRandomData indices200
161− List.map SmallCtorBench.makeRandomData indices200
165− List.map PatternMatchBench.intToNest indices200