on master help sign in
Add small if benchmark, fix messages
commit3434bbddfebedc659e6de3cbe6bb2b08f25a9022 authorjmite <jmitdase@gmail.com> dateThu 20 Aug 2015, 15:10 (11 years ago) parent6384b3c
2 files changed+32−1
bench/CompilerBenchmarks.elm+2−1 bench/src/IfBench.elm+30
bench/CompilerBenchmarks.elm+2−1
@@ -37,7 +37,8 @@ mySuite =
3737 , Benchmark.bench1 "Access 10-constructor Type 200 times: " SmallCtorBench.sumFieldsList smallCtorData200
3838
3939 , Benchmark.bench1 "Tail-recursive if function, called 200 times: " IfBench.tailRecSum indices200
40− , Benchmark.bench1 "Tail-recursive if function, called 200 times: " IfBench.manyConditionalSum indices200
40+ , Benchmark.bench1 "If expression with 20 branches, called 200 times: " IfBench.manyConditionalSum indices200
41+ , Benchmark.bench1 "If expression with 4 branches, called 200 times: " IfBench.fewConditionalSum indices200
4142
4243 , Benchmark.bench1 "Pattern match 18-levels deep, use all values, 200 times " PatternMatchBench.deepMatchSum nestedData200
4344 , Benchmark.bench1 "Pattern match 18-levels deep, 16 wildcards, 200 times " PatternMatchBench.wildcardMatchSum nestedData200
bench/src/IfBench.elm+30
@@ -39,6 +39,32 @@ manyConditionFunction i =
3939 59.0 + (toFloat i)
4040 | (i == 105) ->
4141 69.0 + (toFloat i)
42+ | (i == 106) ->
43+ 39.0 + (toFloat i)
44+ | (i == 107) ->
45+ 38.0 + (toFloat i)
46+ | (i == 108) ->
47+ 49.0 + (toFloat i)
48+ | (i == 109) ->
49+ 59.0 + (toFloat i)
50+ | (i == 110) ->
51+ 69.0 + (toFloat i)
52+ | (i == 111) ->
53+ 39.0 + (toFloat i)
54+ | (i == 115) ->
55+ 69.0 + (toFloat i)
56+ | otherwise ->
57+ toFloat i
58+
59+
60+fewConditionFunction i =
61+ if
62+ | i <= 0 ->
63+ 30.0 + (toFloat i)
64+ | (i == 104) ->
65+ 59.0 + (toFloat i)
66+ | (i == 105) ->
67+ 69.0 + (toFloat i)
4268 | otherwise ->
4369 toFloat i
4470
@@ -48,4 +74,8 @@ tailRecSum intList =
4874
4975manyConditionalSum intList =
5076 List.foldr (\i sumSoFar -> sumSoFar + manyConditionFunction i ) 0.0 intList
77+
78+
79+fewConditionalSum intList =
80+ List.foldr (\i sumSoFar -> sumSoFar + fewConditionFunction i ) 0.0 intList
5181