Elm Exactly
Results / elm-core /

ArrayAppendRepeatedTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Growing an `Array` by 100 successive `Array.append` calls, three elements at a time, keeps
every element in order.

Step `count` appends `[ count, count + 1, count + 2 ]`, counting down from 100, so the result
has 300 elements, starts with 100 and ends with 3 (from the final step's `[ 1, 2, 3 ]`).

Results

elm-0.19.1

passran in 55 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
finalLength: 300
firstElem: Just 100
lastElem: Just 3

elm-0.19.2

passran in 53 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
finalLength: 300
firstElem: Just 100
lastElem: Just 3

elm-0.19.3

passran in 75 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
finalLength: 300
firstElem: Just 100
lastElem: Just 3

lamdera-1.5.0

passran in 70 ms
Output
finalLength: 300
firstElem: Just 100
lastElem: Just 3

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-core/ArrayAppendRepeatedTest] in its title.

Source

The -- CHECK: lines give the expected output.

module ArrayAppendRepeatedTest exposing (main)
{-| Growing an `Array` by 100 successive `Array.append` calls, three elements at a time, keeps
every element in order.
Step `count` appends `[ count, count + 1, count + 2 ]`, counting down from 100, so the result
has 300 elements, starts with 100 and ends with 3 (from the final step's `[ 1, 2, 3 ]`).
-}
-- CHECK: finalLength: 300
-- CHECK: firstElem: Just 100
-- CHECK: lastElem: Just 3
import Array exposing (Array)
import Html exposing (text)
loop : Int -> Array Int -> Array Int
loop count acc =
if count <= 0 then
acc
else
loop (count - 1) (Array.append acc (Array.fromList [ count, count + 1, count + 2 ]))
main =
let
result =
loop 100 Array.empty
_ = Debug.log "finalLength" (Array.length result)
_ = Debug.log "firstElem" (Array.get 0 result)
_ = Debug.log "lastElem" (Array.get (Array.length result - 1) result)
in
text "done"