diff options
Diffstat (limited to 'samples')
-rw-r--r-- | samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java | 25 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html | 20 | ||||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/animated-flag.gif | bin | 0 -> 3650 bytes | |||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/grass-texture-small.jpg | bin | 0 -> 18756 bytes | |||
-rw-r--r-- | samples/src/main/java/gwtquery/samples/public/racetrack.html | 30 |
5 files changed, 51 insertions, 24 deletions
diff --git a/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java b/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java index c503d3c6..fbf4512c 100644 --- a/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java +++ b/samples/src/main/java/gwtquery/samples/client/GwtQueryBenchModule.java @@ -4,11 +4,14 @@ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.query.client.DeferredGQuery;
import com.google.gwt.query.client.SelectorEngine;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.IncrementalCommand;
+import com.google.gwt.user.client.ui.HTML;
public class GwtQueryBenchModule implements EntryPoint {
@@ -30,10 +33,18 @@ public class GwtQueryBenchModule implements EntryPoint { final MySelectors m = GWT.create(MySelectors.class);
final DeferredGQuery dg[] = m.getAllSelectors();
- initResultsTable(dg, "Compiled GQuery", GCOMPILED, "jQuery"
+ HTML h = HTML.wrap(Document.get().getElementById("startrace"));
+ initResultsTable(dg, "GQuery", GCOMPILED, "jQuery"
/*"DOMAssistant 2.7" */, JQUERY, "Dojo", DOJO, "Prototype", PROTOTYPE);
- runBenchmarks(dg, new GQueryCompiledBenchmark(), new JQueryBenchmark(),
- new DojoBenchmark(), new PrototypeBenchmark());
+
+ h.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+
+ runBenchmarks(dg, new GQueryCompiledBenchmark(), new JQueryBenchmark(),
+ new DojoBenchmark(), new PrototypeBenchmark());
+ }
+ });
+
}
public interface Benchmark {
@@ -97,7 +108,11 @@ public class GwtQueryBenchModule implements EntryPoint { (((int) (totalTimes[i] * 100)) / 100.0) + " ms");
setResultClass(benchmark[i].getId(), dg.length,
totalTimes[i] <= min ? "win" : "lose");
+ if (totalTimes[i] <= min) {
+ flagWinner(benchmark[i].getId());
+ }
}
+
return false;
}
}
@@ -128,6 +143,10 @@ public class GwtQueryBenchModule implements EntryPoint { });
}
+ private native void flagWinner(String id) /*-{
+ $wnd.flagWinner(id);
+ }-*/;
+
private native void moveHorse(String id, double totalMovement) /*-{
$wnd.moveHorse(id, totalMovement);
}-*/;
diff --git a/samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html b/samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html index 9b4218a0..44e930e3 100644 --- a/samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html +++ b/samples/src/main/java/gwtquery/samples/public/GwtQueryBench.html @@ -14,6 +14,16 @@ <!--})-->
<!--</script>-->
<style>
+ * {
+ font-family: "Lucida Grande",Helvetica,Arial,sans-serif;
+ color: white;
+ }
+
+ body {
+ background-color: black;
+ }
+
+
.win {
background-color: green;
color: white
@@ -33,18 +43,18 @@ background-color: black;
color: white
}
-
- </style>
+
+ </style>
</head>
<body>
-<h2 style="font-family: Verdana; text-decoration: underline">GWTSpeed - GWTQuery
- benchmarks</h2>
+<h2 style="width: 790px; color: white; border-bottom: 1px solid gray">GWTSpeed - GWT Query
+ benchmarks<div id="startrace" style="float: right; color: red">Start Race</div></h2>
<iframe id="racetrack" src="racetrack.html" width="800" height="310" frameborder="0" marginheight="0" marginwidth="0"></iframe>
<iframe id="jquerybench" src="jquerybench.html" style="display: none"></iframe>
<iframe id="dojobench" src="dojobench.html" style="display: none"></iframe>
<iframe id="prototypebench" src="prototypebench.html" style="display: none"></iframe>
-<code style="display: block; height: 200px; width:780px; overflow-y:scroll">
+<code style="display: block; height: 200px; width:790px; overflow-y:scroll; overflow-x: hidden">
<table id="resultstable" border="1" style="width: 780px; border-collapse: collapse">
</table>
diff --git a/samples/src/main/java/gwtquery/samples/public/animated-flag.gif b/samples/src/main/java/gwtquery/samples/public/animated-flag.gif Binary files differnew file mode 100644 index 00000000..ea93eeb9 --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/animated-flag.gif diff --git a/samples/src/main/java/gwtquery/samples/public/grass-texture-small.jpg b/samples/src/main/java/gwtquery/samples/public/grass-texture-small.jpg Binary files differnew file mode 100644 index 00000000..3689b8bf --- /dev/null +++ b/samples/src/main/java/gwtquery/samples/public/grass-texture-small.jpg diff --git a/samples/src/main/java/gwtquery/samples/public/racetrack.html b/samples/src/main/java/gwtquery/samples/public/racetrack.html index ca937868..de448d6d 100644 --- a/samples/src/main/java/gwtquery/samples/public/racetrack.html +++ b/samples/src/main/java/gwtquery/samples/public/racetrack.html @@ -2,7 +2,8 @@ <head> <title>Benchmark Racetrack</title> <script type="text/javascript"> - var horses = {};// var intervals = {}; + var horses = {}; + window.parent.moveHorse = function(id, amt) { var elt = document.getElementById(id + "horse"); var pos = horses[id]; @@ -11,21 +12,15 @@ } horses[id] = pos + amt; elt.style.left = '' + horses[id] + 'px'; + } - // var start = new Date().getTime(); - // if(intervals[id]) { - // clearInterval(intervals[id]); - // } - // intervals[id]=setInterval(function() { - // end = new Date().getTime(); - // if(end-start > 300) { - // elt.style.left = '' + horses[id] + 'px'; - // clearInterval(intervals[id]); - // } else { - // elt.style.left = '' + pos + amt * (end-start)/300 + 'px'; - // } - // }, 20); - + window.parent.flagWinner = function(id) { + var img = document.createElement("img"); + img.src = "animated-flag.gif"; + var elt = document.getElementById(id + "horse"); + elt.appendChild(img); + img.style.position = 'fixed'; + img.style.left = horses[id]; } </script> <style type="text/css"> @@ -42,12 +37,15 @@ font-weight: bold; font-size: 150%; color: white; + /*left: -70px;*/ + /*top: -30px;*/ + /*position: relative;*/ } </style> </head> <body style="overflow: hidden"> <div id="racefield" - style="width:790px; background-image: url(grass-texture.jpg)"> + style="width:790px; background-image: url(grass-texture-small.jpg); background-repeat: repeat;"> <div id="gwthorse" class="horse"> <img src="horse.png"><span>GWT</span><br> </div> |