mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-12-01 19:35:08 +03:00
add record updates to benching example
This commit is contained in:
parent
2d4d7d8ae8
commit
b468b77a9c
@ -37,17 +37,35 @@ addMyType mine sum =
|
||||
sum
|
||||
|
||||
|
||||
type alias MyRecord =
|
||||
{ one : Int
|
||||
, two : Int
|
||||
, three : Int
|
||||
|
||||
}
|
||||
|
||||
main : BenchmarkProgram
|
||||
main =
|
||||
Benchmark.Runner.program suite
|
||||
|
||||
|
||||
updateRecord attr record =
|
||||
{ record | one = 87 }
|
||||
|
||||
suite : Benchmark
|
||||
suite =
|
||||
describe "List of MyType"
|
||||
[ -- nest as many descriptions as you like
|
||||
describe "slice"
|
||||
[ benchmark "sum 1000 entities in a list" <|
|
||||
describe "Benchmarks"
|
||||
[
|
||||
benchmark "sum 1000 entities in a list" <|
|
||||
\_ -> List.foldl addMyType 0 many
|
||||
]
|
||||
|
||||
, benchmark "1000 record updates" <|
|
||||
\_ -> List.foldl updateRecord
|
||||
{ one = 1
|
||||
, two = 2
|
||||
, three = 3
|
||||
|
||||
}
|
||||
|
||||
many
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user