Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.

Commit a138dcb

Browse files
author
Jaroslav Tulach
committed
Run Graal Polyglot as well as Script Engine sample
1 parent 420b7d3 commit a138dcb

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/main/java/com/mycompany/app/App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static long benchNashornScriptEngine() throws IOException {
108108
}
109109
}
110110

111-
private static long benchGraalScriptEngine() throws IOException {
111+
static long benchGraalScriptEngine() throws IOException {
112112
System.out.println("=== Graal.js via javax.script.ScriptEngine ===");
113113
ScriptEngine graaljsEngine = new ScriptEngineManager().getEngineByName("graal.js");
114114
if (graaljsEngine == null) {
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
package com.mycompany.app;
22

33
import static org.junit.Assert.fail;
4+
import org.junit.BeforeClass;
45
import org.junit.Test;
56

67
public class AppTest {
8+
private static long nashorn;
9+
10+
@BeforeClass
11+
public static void nashornBenchmark() throws Exception {
12+
nashorn = App.benchNashornScriptEngine();
13+
}
14+
715
@Test
8-
public void testSpeed() throws Exception {
9-
long nashorn = App.benchNashornScriptEngine();
16+
public void testGraalPolyglotSpeed() throws Exception {
1017
long graalJS = App.benchGraalPolyglotContext();
1118
if (nashorn < graalJS) {
1219
fail(String.format("Graal.js (%d ms) should be faster than Nashorn (%d ms).", graalJS, nashorn));
1320
}
1421
}
22+
23+
@Test
24+
public void testGraalScriptEngineSpeed() throws Exception {
25+
long graalJS = App.benchGraalScriptEngine();
26+
if (nashorn < graalJS) {
27+
fail(String.format("Graal.js (%d ms) should be faster than Nashorn (%d ms).", graalJS, nashorn));
28+
}
29+
}
1530
}

0 commit comments

Comments
 (0)