File tree Expand file tree Collapse file tree 3 files changed +48
-4
lines changed Expand file tree Collapse file tree 3 files changed +48
-4
lines changed Original file line number Diff line number Diff line change @@ -126,4 +126,46 @@ Expected output:
126126## RFC-8259 validation (example02)
127127
128128An example of a command line application that reads the system input, parses and validates JSON according to the latest
129- specification and in case of any error prints it to the system error output
129+ specification and in case of any error prints it to the system error output.
130+
131+ ### Build uber jar, print its size, and measure its start up time
132+
133+ ``` sh
134+ scala-cli --power package --assembly example02.sc --force -o example02.jar
135+ ls -l ./example02.jar
136+ time ./example02.jar < test.json 2> /dev/null
137+ ```
138+ Expected output:
139+ ``` text
140+ real 0m0.087s
141+ user 0m0.112s
142+ sys 0m0.022s
143+ ```
144+
145+ ### Build GraalVM native image, print its size, and measure its start up time
146+
147+ ``` sh
148+ scala-cli --power package --jvm graalvm --native-image example02.sc --force -o example02_graalvm.bin
149+ ls -l ./example02_graalvm.bin
150+ time ./example02_graalvm.bin < test.json 2> /dev/null
151+ ```
152+ Expected output:
153+ ``` text
154+ real 0m0.004s
155+ user 0m0.000s
156+ sys 0m0.003s
157+ ```
158+
159+ ### Build Scala Native image, print its size, and measure its start up time
160+
161+ ``` sh
162+ scala-cli --power package --native-version 0.4.16 --native example02.sc --force -o example02_native.bin
163+ ls -l ./example02_native.bin
164+ time ./example02_native.bin < test.json 2> /dev/null
165+ ```
166+ Expected output:
167+ ``` text
168+ real 0m0.004s
169+ user 0m0.004s
170+ sys 0m0.000s
171+ ```
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ val jsonCodec: JsonValueCodec[Unit] = new JsonValueCodec[Unit] {
77
88 override def encodeValue (x : Unit , out : JsonWriter ): Unit = ???
99
10- override def nullValue () : Unit = ()
10+ override def nullValue : Unit = ()
1111
1212 private [this ] def decode (in : JsonReader , depth : Int ): Unit = {
1313 val b = in.nextToken()
@@ -43,10 +43,11 @@ val jsonCodec: JsonValueCodec[Unit] = new JsonValueCodec[Unit] {
4343 }) ()
4444 if (! in.isCurrentToken('}' )) in.objectEndOrCommaError()
4545 }
46- } else in.readNullOrError(nullValue() , " expected JSON value" )
46+ } else in.readNullOrError(nullValue, " expected JSON value" )
4747 }
4848}
4949
50- try readFromStream(System .in)(jsonCodec) catch {
50+ val config = ReaderConfig .withPreferredBufSize(1024 * 1024 ).withPreferredCharBufSize(1024 * 1024 )
51+ try readFromStream(System .in, config)(jsonCodec) catch {
5152 case ex : Throwable => ex.printStackTrace(System .err)
5253}
Original file line number Diff line number Diff line change 1+ {"x:123 }
You can’t perform that action at this time.
0 commit comments