File tree Expand file tree Collapse file tree 3 files changed +45
-214
lines changed Expand file tree Collapse file tree 3 files changed +45
-214
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ user 0m34.748s
198
198
sys 0m2.362s
199
199
```
200
200
201
- ### Build GraalVM native image, print its size, and measure its running time (tested with Oracle GraalVM 24/23 )
201
+ ### Build GraalVM native image, print its size, and measure its running time (tested with Oracle GraalVM 24)
202
202
203
203
``` sh
204
204
scala-cli --power package --graalvm-jvm-id graalvm-oracle:24 --native-image example02.sc --force -o example02_graalvm.bin -- --no-fallback --gc=epsilon -O3 -H:+UnlockExperimentalVMOptions -R:MaxHeapSize=16m -H:-GenLoopSafepoints -H:-ParseRuntimeOptions -H:-IncludeMethodData --initialize-at-build-time
@@ -225,3 +225,34 @@ real 0m49.766s
225
225
user 0m47.408s
226
226
sys 0m2.355s
227
227
```
228
+
229
+ ## Benchmarking ` Math.multiplyHigh ` (example03)
230
+
231
+ ### Build uber jar and measure its running time (tested with Open JDK 21)
232
+
233
+ ``` sh
234
+ scala-cli --power package --assembly example03.scala --force -o example03.jar
235
+ time ./example03.jar -J-XX:+UnlockExperimentalVMOptions -J-XX:+UseEpsilonGC -J-Xms32m -J-Xmx32m -J-XX:+AlwaysPreTouch
236
+ ```
237
+ Expected output:
238
+ ``` text
239
+ 9223372036854775806
240
+
241
+ real 0m11.017s
242
+ user 0m11.059s
243
+ sys 0m0.038s
244
+ ```
245
+
246
+ ### Build Scala Native image and measure its running time
247
+ ``` sh
248
+ scala-cli --power package --native-version 0.5.8 --native example03.scala --native-mode release-full --native-gc none --native-lto thin --native-multithreading=false --force -o example03_native.bin
249
+ time ./example03_native.bin
250
+ ```
251
+ Expected output:
252
+ ``` text
253
+ 9223372036854775806
254
+
255
+ real 0m16.668s
256
+ user 0m16.660s
257
+ sys 0m0.006s
258
+ ```
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ //> using dep " com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-core::2.36.3"
2
+
3
+ package com .github .plokhotnyuk .jsoniter_scala .core
4
+
5
+ object Main extends App {
6
+ var r = 0x3333333333333333L
7
+ var i = 1L
8
+ while (i <= 10000000000L ) {
9
+ r += Math .multiplyHigh(r, i) // Replace by `NativeMath.multiplyHigh` for Scala Native
10
+ i += 1L
11
+ }
12
+ println(r)
13
+ }
You can’t perform that action at this time.
0 commit comments