File tree 3 files changed +48
-4
lines changed
3 files changed +48
-4
lines changed Original file line number Diff line number Diff line change @@ -126,4 +126,46 @@ Expected output:
126
126
## RFC-8259 validation (example02)
127
127
128
128
An 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] {
7
7
8
8
override def encodeValue (x : Unit , out : JsonWriter ): Unit = ???
9
9
10
- override def nullValue () : Unit = ()
10
+ override def nullValue : Unit = ()
11
11
12
12
private [this ] def decode (in : JsonReader , depth : Int ): Unit = {
13
13
val b = in.nextToken()
@@ -43,10 +43,11 @@ val jsonCodec: JsonValueCodec[Unit] = new JsonValueCodec[Unit] {
43
43
}) ()
44
44
if (! in.isCurrentToken('}' )) in.objectEndOrCommaError()
45
45
}
46
- } else in.readNullOrError(nullValue() , " expected JSON value" )
46
+ } else in.readNullOrError(nullValue, " expected JSON value" )
47
47
}
48
48
}
49
49
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 {
51
52
case ex : Throwable => ex.printStackTrace(System .err)
52
53
}
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