mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-11-29 12:46:32 +03:00
add benchmarkable test case
This commit is contained in:
parent
a1c0154534
commit
112c74253a
53
testcases/bench/Main.elm
Normal file
53
testcases/bench/Main.elm
Normal file
@ -0,0 +1,53 @@
|
||||
module Main exposing (main)
|
||||
|
||||
{-| -}
|
||||
|
||||
import Benchmark exposing (..)
|
||||
import Benchmark.Runner exposing (BenchmarkProgram, program)
|
||||
import Html
|
||||
|
||||
|
||||
type MyType
|
||||
= Zero
|
||||
| One Int
|
||||
| Two String String
|
||||
|
||||
|
||||
values =
|
||||
[ Zero
|
||||
, One 5
|
||||
, Two "Two" "two"
|
||||
]
|
||||
|
||||
|
||||
many =
|
||||
List.repeat 1000 values
|
||||
|> List.concat
|
||||
|
||||
|
||||
addMyType mine sum =
|
||||
case mine of
|
||||
Zero ->
|
||||
sum
|
||||
|
||||
One i ->
|
||||
i + sum
|
||||
|
||||
Two _ _ ->
|
||||
sum
|
||||
|
||||
|
||||
main : BenchmarkProgram
|
||||
main =
|
||||
Benchmark.Runner.program suite
|
||||
|
||||
|
||||
suite : Benchmark
|
||||
suite =
|
||||
describe "List of MyType"
|
||||
[ -- nest as many descriptions as you like
|
||||
describe "slice"
|
||||
[ benchmark "sum 1000 entities in a list" <|
|
||||
\_ -> List.foldl addMyType 0 many
|
||||
]
|
||||
]
|
29
testcases/bench/elm.json
Normal file
29
testcases/bench/elm.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"type": "application",
|
||||
"source-directories": [
|
||||
"."
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
"dependencies": {
|
||||
"direct": {
|
||||
"elm/browser": "1.0.2",
|
||||
"elm/core": "1.0.5",
|
||||
"elm/html": "1.0.0",
|
||||
"elm-explorations/benchmark": "1.0.1"
|
||||
},
|
||||
"indirect": {
|
||||
"BrianHicks/elm-trend": "2.1.3",
|
||||
"Skinney/murmur3": "2.0.8",
|
||||
"elm/json": "1.1.3",
|
||||
"elm/regex": "1.0.0",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/url": "1.0.0",
|
||||
"elm/virtual-dom": "1.0.2",
|
||||
"mdgriffith/style-elements": "5.0.1"
|
||||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
14835
testcases/bench/output/elm.js
Normal file
14835
testcases/bench/output/elm.js
Normal file
File diff suppressed because it is too large
Load Diff
10224
testcases/bench/output/elm.opt.js
Normal file
10224
testcases/bench/output/elm.opt.js
Normal file
File diff suppressed because it is too large
Load Diff
9874
testcases/bench/output/elm.opt.transformed.js
Normal file
9874
testcases/bench/output/elm.opt.transformed.js
Normal file
File diff suppressed because it is too large
Load Diff
18
testcases/bench/standard.html
Normal file
18
testcases/bench/standard.html
Normal file
@ -0,0 +1,18 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Main</title>
|
||||
<script src="output/elm.opt.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="myapp"></div>
|
||||
<script>
|
||||
var app = Elm.Main.init({
|
||||
node: document.getElementById('myapp')
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
18
testcases/bench/transformed.html
Normal file
18
testcases/bench/transformed.html
Normal file
@ -0,0 +1,18 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Main</title>
|
||||
<script src="output/elm.opt.transformed.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="myapp"></div>
|
||||
<script>
|
||||
var app = Elm.Main.init({
|
||||
node: document.getElementById('myapp')
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user