diff --git a/teavm-samples/teavm-samples-benchmark/pom.xml b/teavm-samples/teavm-samples-benchmark/pom.xml
index 7b2bbe6d3..ffdbe10cd 100644
--- a/teavm-samples/teavm-samples-benchmark/pom.xml
+++ b/teavm-samples/teavm-samples-benchmark/pom.xml
@@ -76,6 +76,11 @@
html5-canvas
0.7.1
+
+ org.netbeans.html
+ net.java.html.boot
+ 1.1
+
@@ -194,10 +199,47 @@
org.apache.maven.plugins
maven-source-plugin
+
+ org.netbeans.html
+ html4j-maven-plugin
+ 1.1
+
+
+
+ process-js-annotations
+
+
+
+
org.apache.maven.plugins
maven-javadoc-plugin
+
+
+ fx
+
+
+ org.netbeans.html
+ net.java.html.boot.fx
+ 1.1
+ runtime
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.3.2
+
+ org.teavm.samples.benchmark.bck2brwsr.BenchmarkFX
+
+
+
+
+
+
\ No newline at end of file
diff --git a/teavm-samples/teavm-samples-benchmark/src/main/java/org/teavm/samples/benchmark/bck2brwsr/BenchmarkFX.java b/teavm-samples/teavm-samples-benchmark/src/main/java/org/teavm/samples/benchmark/bck2brwsr/BenchmarkFX.java
new file mode 100644
index 000000000..0a0336f4c
--- /dev/null
+++ b/teavm-samples/teavm-samples-benchmark/src/main/java/org/teavm/samples/benchmark/bck2brwsr/BenchmarkFX.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015 jarda.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.samples.benchmark.bck2brwsr;
+
+import net.java.html.boot.BrowserBuilder;
+
+public class BenchmarkFX {
+ public static void main(String... args) {
+ BrowserBuilder.newBrowser().loadPage("fx.html")
+ .loadClass(BenchmarkStarter.class)
+ .invoke("main")
+ .showAndWait();
+ System.exit(0);
+ }
+
+}
diff --git a/teavm-samples/teavm-samples-benchmark/src/main/java/org/teavm/samples/benchmark/bck2brwsr/BenchmarkStarter.java b/teavm-samples/teavm-samples-benchmark/src/main/java/org/teavm/samples/benchmark/bck2brwsr/BenchmarkStarter.java
index 522073531..e0346b627 100644
--- a/teavm-samples/teavm-samples-benchmark/src/main/java/org/teavm/samples/benchmark/bck2brwsr/BenchmarkStarter.java
+++ b/teavm-samples/teavm-samples-benchmark/src/main/java/org/teavm/samples/benchmark/bck2brwsr/BenchmarkStarter.java
@@ -20,6 +20,8 @@ import com.dukescript.api.canvas.Style;
import com.dukescript.canvas.html.HTML5Graphics;
import java.util.Timer;
import java.util.TimerTask;
+import net.java.html.BrwsrCtx;
+import net.java.html.js.JavaScriptBody;
import org.jbox2d.collision.shapes.CircleShape;
import org.jbox2d.collision.shapes.PolygonShape;
import org.jbox2d.collision.shapes.Shape;
@@ -35,28 +37,30 @@ public class BenchmarkStarter {
private static double startMillisecond;
private static int currentSecond;
private static double timeSpentCalculating;
+ private static BrwsrCtx ctx;
public static void main(String[] args) {
startMillisecond = System.currentTimeMillis();
+ ctx = BrwsrCtx.findDefault(BenchmarkStarter.class);
makeStep();
}
+
+ static void makeStep() {
+ ctx.execute(new Runnable() {
+ @Override
+ public void run() {
+ makeStep0();
+ }
+ });
+ }
- private static void makeStep() {
+ private static void makeStep0() {
double start = System.currentTimeMillis();
scene.calculate();
double end = System.currentTimeMillis();
int second = (int)((System.currentTimeMillis() - startMillisecond) / 1000);
if (second > currentSecond) {
- /*
- HTMLElement row = document.createElement("tr");
- resultTableBody.appendChild(row);
- HTMLElement secondCell = document.createElement("td");
- row.appendChild(secondCell);
- secondCell.appendChild(document.createTextNode(String.valueOf(second)));
- HTMLElement timeCell = document.createElement("td");
- row.appendChild(timeCell);
- timeCell.appendChild(document.createTextNode(String.valueOf(timeSpentCalculating)));
-*/
+ publishResults(second, timeSpentCalculating);
timeSpentCalculating = 0;
currentSecond = second;
}
@@ -109,4 +113,17 @@ public class BenchmarkStarter {
}
context.restore();
}
+
+ @JavaScriptBody(args = { "second", "timeSpentCalculating" }, body =
+ "var resultTableBody = document.getElementById('result-table-body');\n" +
+ "var row = document.createElement(\"tr\");\n" +
+ "resultTableBody.appendChild(row);\n" +
+ "var secondCell = document.createElement(\"td\");\n" +
+ "row.appendChild(secondCell);\n" +
+ "secondCell.appendChild(document.createTextNode(second));\n" +
+ "var timeCell = document.createElement(\"td\");\n" +
+ "row.appendChild(timeCell);\n" +
+ "timeCell.appendChild(document.createTextNode(timeSpentCalculating));\n"
+ )
+ private static native void publishResults(int second, double time);
}
diff --git a/teavm-samples/teavm-samples-benchmark/src/main/resources/org/teavm/samples/benchmark/bck2brwsr/fx.html b/teavm-samples/teavm-samples-benchmark/src/main/resources/org/teavm/samples/benchmark/bck2brwsr/fx.html
new file mode 100644
index 000000000..f37320506
--- /dev/null
+++ b/teavm-samples/teavm-samples-benchmark/src/main/resources/org/teavm/samples/benchmark/bck2brwsr/fx.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+ HotSpot/JavaFX jbox2d benchmark
+
+
+ HotSpot/JavaFX performance
+
+
+
+
+
+
+ Second |
+ Time spent computing, ms |
+
+
+
+
+
+