Elm Exactly
Results / elm-json /

JsonEncodeBigStringTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Checks that `Json.Encode.string` encodes a 5000-character string as a quoted JSON string.

The string is built with `String.repeat`, and the length of the encoded text is
printed: 5000 characters plus two quotes gives 5002.

Results

elm-0.19.1

passran in 58 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
JsonEncodeBigStringTest: 5002

elm-0.19.2

passran in 54 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
JsonEncodeBigStringTest: 5002

elm-0.19.3

passran in 76 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
JsonEncodeBigStringTest: 5002

lamdera-1.5.0

passran in 43 ms
Output
JsonEncodeBigStringTest: 5002

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module JsonEncodeBigStringTest exposing (main)
{-| Checks that `Json.Encode.string` encodes a 5000-character string as a quoted JSON string.
The string is built with `String.repeat`, and the length of the encoded text is
printed: 5000 characters plus two quotes gives 5002.
-}
-- CHECK: JsonEncodeBigStringTest: 5002
import Html exposing (text)
import Json.Encode as E
main =
let
encoded =
E.encode 0 (E.string (String.repeat 5000 "x"))
_ =
Debug.log "JsonEncodeBigStringTest" (String.length encoded)
in
text "ok"