StringRopeFoldlSliceTest
Checks `String.foldl` and `String.reverse` over a 40000-character string built by 400 successive appends. Each append adds `"abcdefghij"` repeated 10 times. Counting characters with `String.foldl` must give 40000, and the reversed string must begin with `"jihgfedcba"`.
Results
elm-0.19.1
passran in 99 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. rope_count: 40000 rope_rev_head: "jihgfedcba"
elm-0.19.2
passran in 87 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. rope_count: 40000 rope_rev_head: "jihgfedcba"
elm-0.19.3
passran in 60 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. rope_count: 40000 rope_rev_head: "jihgfedcba"
lamdera-1.5.0
passran in 65 msOutput
rope_count: 40000 rope_rev_head: "jihgfedcba"
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/StringRopeFoldlSliceTest] in its title.
Source
The -- CHECK: lines give the expected output.
module StringRopeFoldlSliceTest exposing (main)
{-| Checks `String.foldl` and `String.reverse` over a 40000-character string built by 400 successive appends.
Each append adds `"abcdefghij"` repeated 10 times. Counting characters with
`String.foldl` must give 40000, and the reversed string must begin with
`"jihgfedcba"`.
-}
-- CHECK: rope_count: 40000
-- CHECK: rope_rev_head: "jihgfedcba"
import Html exposing (text)
main =
let
chunk =
String.repeat 10 "abcdefghij"
big =
List.foldl (\_ acc -> acc ++ chunk) "" (List.range 1 400)
_ =
Debug.log "rope_count" (String.foldl (\_ n -> n + 1) 0 big)
_ =
Debug.log "rope_rev_head" (String.left 10 (String.reverse big))
in
text "done"