aboutsummaryrefslogtreecommitdiffstats
path: root/samples/src
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2011-04-12 23:14:46 +0000
committerManolo Carrasco <manolo@apache.org>2011-04-12 23:14:46 +0000
commit1e84a3b238b902ada3b50505479bab5d224ec83d (patch)
treeb9bc7d7adb1f1999e9292ec1f5ba8eff9b711f3f /samples/src
parente739b2414640e62456613ece6bfd909d6de9f8ef (diff)
downloadgwtquery-1e84a3b238b902ada3b50505479bab5d224ec83d.tar.gz
gwtquery-1e84a3b238b902ada3b50505479bab5d224ec83d.zip
adding cache benchmark in the examples index
Diffstat (limited to 'samples/src')
-rw-r--r--samples/src/main/java/gwtquery/samples/client/JsCollectionVsJavaCollection.java35
-rw-r--r--samples/src/main/webapp/index.html2
2 files changed, 14 insertions, 23 deletions
diff --git a/samples/src/main/java/gwtquery/samples/client/JsCollectionVsJavaCollection.java b/samples/src/main/java/gwtquery/samples/client/JsCollectionVsJavaCollection.java
index b4edf9e4..c5bacd46 100644
--- a/samples/src/main/java/gwtquery/samples/client/JsCollectionVsJavaCollection.java
+++ b/samples/src/main/java/gwtquery/samples/client/JsCollectionVsJavaCollection.java
@@ -6,6 +6,7 @@ import java.util.HashMap;
import com.google.gwt.core.client.Duration;
import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.query.client.js.JsCache;
@@ -18,29 +19,23 @@ import com.google.gwt.user.client.ui.RootPanel;
public class JsCollectionVsJavaCollection implements EntryPoint{
- public static final int MAX_ITEMS = 100000;
+ public static final int MAX_ITEMS = GWT.isScript() ? 100000 : 100;
public void onModuleLoad() {
-
Button b = new Button("run test");
b.addClickHandler(new ClickHandler() {
-
public void onClick(ClickEvent event) {
$(".gwt-label").remove();
testJsMapVsHashMap();
}
});
-
RootPanel.get().add(b);
-
}
public void testJsMapVsHashMap() {
- log("Testing jsMap");
-
- log("init phase");
+ log("-------------");
for (int i = 0; i < MAX_ITEMS; i++){
new String(""+i);
}
@@ -56,7 +51,7 @@ public class JsCollectionVsJavaCollection implements EntryPoint{
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
- log("Testing cache : do "+MAX_ITEMS+" get in the cache :");
+ log("Testing cache : get "+MAX_ITEMS+" from the cache :");
ellapsedTime = Duration.currentTimeMillis();
for (int i = 0 ; i < MAX_ITEMS; i++){
int random = Random.nextInt(MAX_ITEMS);
@@ -65,7 +60,7 @@ public class JsCollectionVsJavaCollection implements EntryPoint{
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
- log("Testing cache : do "+MAX_ITEMS+" exist (JsCache.exists() ) in the cache :");
+ log("Testing cache : run "+MAX_ITEMS+" exist() in the cache :");
ellapsedTime = Duration.currentTimeMillis();
for (int i = 0 ; i < MAX_ITEMS; i++){
int random = Random.nextInt(MAX_ITEMS);
@@ -74,14 +69,14 @@ public class JsCollectionVsJavaCollection implements EntryPoint{
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
- log("Testing cache : get all keys :");
+ log("Testing cache : visit all keys() :");
ellapsedTime = Duration.currentTimeMillis();
for (String s: cache.keys()) {
}
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
- log("Testing cache : get all values (JsCache.elements() ) :");
+ log("Testing cache : visit all values() :");
ellapsedTime = Duration.currentTimeMillis();
for (Object o: cache.elements()) {
}
@@ -89,7 +84,7 @@ public class JsCollectionVsJavaCollection implements EntryPoint{
log(" ellapsed Time : "+ellapsedTime);
totalTime = Duration.currentTimeMillis() - totalTime;
- log(" Total : "+ totalTime);
+ log(" Total : "+ totalTime + " ms.");
log("-------------");
log("");
@@ -103,7 +98,7 @@ public class JsCollectionVsJavaCollection implements EntryPoint{
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
- log("Testing hashMap : do "+MAX_ITEMS+" get in the map :");
+ log("Testing hashMap : get "+MAX_ITEMS+" from the map :");
ellapsedTime = Duration.currentTimeMillis();
for (int i = 0 ; i < MAX_ITEMS; i++){
int random = Random.nextInt(MAX_ITEMS);
@@ -112,7 +107,7 @@ public class JsCollectionVsJavaCollection implements EntryPoint{
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
- log("Testing hashMap : do "+MAX_ITEMS+" containsKey() :");
+ log("Testing hashMap : run "+MAX_ITEMS+" containsKey() in the map :");
ellapsedTime = Duration.currentTimeMillis();
for (int i = 0 ; i < MAX_ITEMS; i++){
int random = Random.nextInt(MAX_ITEMS);
@@ -121,14 +116,14 @@ public class JsCollectionVsJavaCollection implements EntryPoint{
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
- log("Testing hashMap : get all keys :");
+ log("Testing hashMap : visit all keySet() :");
ellapsedTime = Duration.currentTimeMillis();
for (String s: hashMap.keySet()) {
}
ellapsedTime = Duration.currentTimeMillis() - ellapsedTime;
log(" ellapsed Time : "+ellapsedTime);
- log("Testing hashMap : get all values :");
+ log("Testing hashMap : visit all values() :");
ellapsedTime = Duration.currentTimeMillis();
for (Object o : hashMap.values()) {
}
@@ -136,16 +131,12 @@ public class JsCollectionVsJavaCollection implements EntryPoint{
log(" ellapsed Time : "+ellapsedTime);
totalTime = Duration.currentTimeMillis() - totalTime;
- log(" Total : "+ totalTime);
+ log(" Total : "+ totalTime + " ms.");
log("-------------");
}
-
-
-
public void log(String msg) {
RootPanel.get().add(new Label(msg));
}
-
}
diff --git a/samples/src/main/webapp/index.html b/samples/src/main/webapp/index.html
index 743cda7c..d7160ec4 100644
--- a/samples/src/main/webapp/index.html
+++ b/samples/src/main/webapp/index.html
@@ -20,7 +20,7 @@
<li><a href="javascript:goTo('FadeEffectsSample/FadeEffectsSample.html')">FadeEffectsSample.html</a></li>
<li><a href="javascript:goTo('SlideEffectsSample/SlideEffectsSample.html')">SlideEffectsSample.html</a></li>
<li><a href="javascript:goTo('AnimationsSample/AnimationsSample.html')">AnimationsSample.html</a></li>
-
+<li><a href="javascript:goTo('JsCollectionVsJavaCollection/JsCollectionVsJavaCollection.html')">JsCollectionVsJavaCollection.html</a></li>
</ul>
</body>
</html>