From: Manolo Carrasco Date: Tue, 12 Apr 2011 23:14:46 +0000 (+0000) Subject: adding cache benchmark in the examples index X-Git-Tag: release-1.3.2~409 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1e84a3b238b902ada3b50505479bab5d224ec83d;p=gwtquery.git adding cache benchmark in the examples index --- diff --git a/samples/pom.xml b/samples/pom.xml index b4a4a04a..5b7a3754 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -45,17 +45,14 @@ true gwtquery.samples.JsCollectionVsJavaCollection - @@ -67,27 +64,6 @@ - - maven-clean-plugin - - - src/main/webapp/gwtquery.samples.GwtQueryBench - src/main/webapp/gwtquery.samples.GwtQueryDemo - src/main/webapp/gwtquery.samples.GwtQueryEffects - src/main/webapp/gwtquery.samples.GwtQueryEffectsMin - src/main/webapp/gwtquery.samples.GwtQueryPlugin - src/main/webapp/gwtquery.samples.GwtQuerySample - src/main/webapp/gwtquery.samples.GwtQueryWidgets - src/main/webapp/gwtquery.samples.GwtQueryImageZoom - src/main/webapp/test - src/main/webapp/WEB-INF/classes - tomcat - www-test - .gwt-tmp - - - - org.apache.maven.plugins maven-eclipse-plugin 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 @@
  • FadeEffectsSample.html
  • SlideEffectsSample.html
  • AnimationsSample.html
  • - +
  • JsCollectionVsJavaCollection.html