Revision: 7366
Author: [email protected]
Date: Thu Jan  7 14:15:09 2010
Log: Adds more widget creation benchmarks. to compare creating via innerHTML v. dom
calls, and empty dom structures v. similar structures with a bit of text.

Reviewed by jgw
http://gwt-code-reviews.appspot.com/129804
http://code.google.com/p/google-web-toolkit/source/detail?r=7366

Added:
/trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDomViaApi.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestEmptyCursorDomCrawl.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestEmptyDom.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestEmptyDomViaApi.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestEmptyRealisticDomCrawl.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestManualHTMLPanel.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/Util.java
Deleted:
/trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestWidget.java
Modified:
/trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/Microbenchmarks.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/Microbenchmarks.ui.xml /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestCursorDomCrawl.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDom.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDomBinder.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDomBinder.ui.xml /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestFlows.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestRealisticDomCrawl.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestWidgetBinder.java /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestWidgetBinder.ui.xml /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/WidgetCreation.java

=======================================
--- /dev/null
+++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDomViaApi.java Thu Jan 7 14:15:09 2010
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * 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 com.google.gwt.reference.microbenchmark.client;
+
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Run by {...@link WidgetCreation}, see {...@link Maker#name} for details.
+ */
+public class TestDomViaApi extends Widget {
+  public static class Maker extends WidgetCreation.Maker {
+    Maker() {
+      super("Text heavy UI via DOM api calls, no widgets");
+    }
+
+    public Widget make() {
+      return new TestDomViaApi();
+    }
+  }
+
+  DivElement root;
+  DivElement div1;
+  DivElement div2;
+  DivElement div3;
+  DivElement div4;
+  SpanElement span1;
+  SpanElement span2;
+
+  private TestDomViaApi() {
+    Document d = Document.get();
+    root = d.createDivElement();
+    root.appendChild(d.createTextNode("Div root"));
+
+    div1 = d.createDivElement();
+    Util.addText(div1, "Div1");
+    root.appendChild(div1);
+
+    div2 = d.createDivElement();
+    Util.addText(div2, "Div2");
+    div1.appendChild(div2);
+
+    span1 = d.createSpanElement();
+    Util.addText(span1, "Span1");
+    div1.appendChild(span1);
+
+    DivElement anon = d.createDivElement();
+    Util.addText(anon, "Div anon");
+    root.appendChild(anon);
+
+    div3 = d.createDivElement();
+    Util.addText(div3, "Div3");
+    anon.appendChild(div3);
+
+    div4 = d.createDivElement();
+    Util.addText(div4, "Div4");
+    div3.appendChild(div4);
+
+    span2 = d.createSpanElement();
+    Util.addText(span2, "Span2");
+    div3.appendChild(span2);
+
+    Util.addText(div1, " Div1 end");
+    Util.addText(div3, " Div3 end");
+    Util.addText(anon, " Div anon end");
+    Util.addText(root, " Div root end");
+
+    setElement(root);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestEmptyCursorDomCrawl.java Thu Jan 7 14:15:09 2010
@@ -0,0 +1,50 @@
+package com.google.gwt.reference.microbenchmark.client;
+
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Run by {...@link WidgetCreation}, see {...@link Maker#name} for details.
+ */
+public class TestEmptyCursorDomCrawl extends Widget {
+  public static class Maker extends WidgetCreation.Maker {
+    Maker() {
+ super("Empty UI via innerHTML, no widgets, get children by idealized crawl");
+    }
+    public Widget make() {
+      return new TestEmptyCursorDomCrawl();
+    }
+  }
+
+  Element elm;
+  DivElement div1;
+  DivElement div2;
+  DivElement div3;
+  DivElement div4;
+  SpanElement span1;
+  SpanElement span2;
+
+  private TestEmptyCursorDomCrawl() {
+    Element root = Util.fromHtml(Util.EMPTY_OUTER_HTML);
+
+    Element cursor = root;
+    div1 = (cursor = cursor.getFirstChildElement()).cast();
+    assert div1.getId().equals("div1");
+    div2 = (cursor = cursor.getFirstChildElement()).cast();
+    assert div2.getId().equals("div2");
+    span1 = (cursor = cursor.getNextSiblingElement()).cast();
+    assert span1.getId().equals("span1");
+
+    cursor = div1.getNextSiblingElement();
+    div3 = (cursor = cursor.getFirstChildElement()).cast();
+    assert div3.getId().equals("div3");
+    div4 = (cursor = cursor.getFirstChildElement()).cast();
+    assert div4.getId().equals("div4");
+    span2 = (cursor = cursor.getNextSiblingElement()).cast();
+    assert span2.getId().equals("span2");
+
+    setElement(root);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestEmptyDom.java Thu Jan 7 14:15:09 2010
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * 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 com.google.gwt.reference.microbenchmark.client;
+
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Run by {...@link WidgetCreation}, see {...@link Maker#name} for details.
+ */
+public class TestEmptyDom extends Widget {
+  public static class Maker extends WidgetCreation.Maker {
+    Maker() {
+      super("Empty UI via innerHTML, no widgets, get children by id");
+    }
+    public Widget make() {
+      return new TestEmptyDom();
+    }
+  }
+
+  Element root;
+  DivElement div1;
+  DivElement div2;
+  DivElement div3;
+
+  DivElement div4;
+  SpanElement span1;
+
+  SpanElement span2;
+
+  private TestEmptyDom() {
+    root = Util.fromHtml(Util.EMPTY_OUTER_HTML);
+
+    Document.get().getBody().appendChild(root);
+    div1 = Document.get().getElementById("div1").cast();
+    div2 = Document.get().getElementById("div2").cast();
+    div3 = Document.get().getElementById("div3").cast();
+    div4 = Document.get().getElementById("div4").cast();
+    span1 = Document.get().getElementById("span1").cast();
+    span2 = Document.get().getElementById("span2").cast();
+
+    Document.get().getBody().removeChild(root);
+    div1.removeAttribute("id");
+    div2.removeAttribute("id");
+    div3.removeAttribute("id");
+    div4.removeAttribute("id");
+    span1.removeAttribute("id");
+    span2.removeAttribute("id");
+
+    setElement(root);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestEmptyDomViaApi.java Thu Jan 7 14:15:09 2010
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * 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 com.google.gwt.reference.microbenchmark.client;
+
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Run by {...@link WidgetCreation}, see {...@link Maker#name} for details.
+ */
+public class TestEmptyDomViaApi extends Widget {
+  public static class Maker extends WidgetCreation.Maker {
+    Maker() {
+      super("Empty UI via DOM api calls, no widgets");
+    }
+
+    public Widget make() {
+      return new TestEmptyDomViaApi();
+    }
+  }
+
+  DivElement root;
+  DivElement div1;
+  DivElement div2;
+  DivElement div3;
+  DivElement div4;
+  SpanElement span1;
+  SpanElement span2;
+
+  private TestEmptyDomViaApi() {
+    Document d = Document.get();
+    root = d.createDivElement();
+    root.appendChild(d.createTextNode("Div root"));
+
+    div1 = d.createDivElement();
+    root.appendChild(div1);
+
+    div2 = d.createDivElement();
+    div1.appendChild(div2);
+
+    span1 = d.createSpanElement();
+    div1.appendChild(span1);
+
+    DivElement anon = d.createDivElement();
+    root.appendChild(anon);
+
+    div3 = d.createDivElement();
+    anon.appendChild(div3);
+
+    div4 = d.createDivElement();
+    div3.appendChild(div4);
+
+    span2 = d.createSpanElement();
+    div3.appendChild(span2);
+
+    setElement(root);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestEmptyRealisticDomCrawl.java Thu Jan 7 14:15:09 2010
@@ -0,0 +1,49 @@
+package com.google.gwt.reference.microbenchmark.client;
+
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Run by {...@link WidgetCreation}, see {...@link Maker#name} for details.
+ */
+public class TestEmptyRealisticDomCrawl extends Widget {
+  public static class Maker extends WidgetCreation.Maker {
+    Maker() {
+ super("Empty UI via innerHTML, no widgets, get children by nav from root");
+    }
+    public Widget make() {
+      return new TestEmptyRealisticDomCrawl();
+    }
+  }
+
+  Element elm;
+  DivElement div1;
+  DivElement div2;
+  DivElement div3;
+  DivElement div4;
+  SpanElement span1;
+
+  SpanElement span2;
+
+  private TestEmptyRealisticDomCrawl() {
+    Element root = Util.fromHtml(Util.EMPTY_OUTER_HTML);
+
+    div1 = root.getFirstChildElement().cast();
+    assert div1.getId().equals("div1");
+    div2 = root.getFirstChildElement().getFirstChildElement().cast();
+    assert div2.getId().equals("div2");
+ span1 = root.getFirstChildElement().getFirstChildElement().getNextSiblingElement().cast();
+    assert span1.getId().equals("span1");
+
+ div3 = root.getFirstChildElement().getNextSiblingElement().getFirstChildElement().cast();
+    assert div3.getId().equals("div3");
+ div4 = root.getFirstChildElement().getNextSiblingElement().getFirstChildElement().getFirstChildElement().cast();
+    assert div4.getId().equals("div4");
+ span2 = root.getFirstChildElement().getNextSiblingElement().getFirstChildElement().getFirstChildElement().getNextSiblingElement().cast();
+    assert span2.getId().equals("span2");
+
+    setElement(root);
+  }
+}
=======================================
--- /dev/null
+++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestManualHTMLPanel.java Thu Jan 7 14:15:09 2010
@@ -0,0 +1,41 @@
+package com.google.gwt.reference.microbenchmark.client;
+
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Run by {...@link WidgetCreation}, see {...@link Maker#name} for details.
+ */
+public class TestManualHTMLPanel extends Composite {
+  public static class Maker extends WidgetCreation.Maker {
+    Maker() {
+      super("Text heavy UI via typical manual HTMLPanel usage");
+    }
+    public Widget make() {
+      return new TestManualHTMLPanel();
+    }
+  }
+  DivElement div1;
+  DivElement div2;
+  DivElement div3;
+  DivElement div4;
+  SpanElement span1;
+
+
+  SpanElement span2;
+
+  private TestManualHTMLPanel() {
+    HTMLPanel p = new HTMLPanel(Util.TEXTY_INNER_HTML);
+    initWidget(p);
+
+    div1 = p.getElementById("div1").cast();
+    div2 = p.getElementById("div2").cast();
+    div3 = p.getElementById("div3").cast();
+    div4 = p.getElementById("div4").cast();
+    span1 = p.getElementById("span1").cast();
+    span2 = p.getElementById("span2").cast();
+  }
+}
=======================================
--- /dev/null
+++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/Util.java Thu Jan 7 14:15:09 2010
@@ -0,0 +1,64 @@
+package com.google.gwt.reference.microbenchmark.client;
+
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.i18n.client.NumberFormat;
+
+class Util {
+ private static final DivElement detachedDiv = Document.get().createDivElement();
+
+ static final String EMPTY_OUTER_HTML = "<div>" + Util.EMPTY_INNER_HTML + "</div>";
+
+  static final String EMPTY_INNER_HTML = "<div id='div1'>"
+    +     "<div id='div2'></div>"
+    +     "<span id='span1'></span>"
+    +   "</div>"
+    +   "<div>"
+    +     "<div id='div3'>"
+    +       "<div id='div4'></div>"
+    +       "<span id='span2'></span>"
+    +     "</div>"
+    +   "</div>";
+
+ static final String TEXTY_OUTER_HTML = "<div>" + Util.TEXTY_INNER_HTML + "</div>";
+
+  static final String TEXTY_INNER_HTML = "Div root start"
+  +   "<div id='div1'>Div1 start"
+  +     "<div id='div2'>Div2</div>"
+  +     "<span id='span1'>Span1</span>"
+  +   "Div1 end</div>"
+  +   "<div>Div anon start"
+  +     "<div id='div3'>Div3"
+  +       "<div id='div4'>Div4</div>"
+  +       "<span id='span2'>Span2</span>"
+  +     "Div 3 end</div>"
+  +   "Div anon end</div>"
+  + "Div root end";
+
+  static void addText(Element elm, String text) {
+    elm.appendChild(Document.get().createTextNode(text));
+  }
+
+  static Element fromHtml(String html) {
+    Util.detachedDiv.setInnerHTML(html);
+    Element e = Util.detachedDiv.getFirstChildElement();
+    e.getParentElement().removeChild(e);
+    return e;
+  }
+
+  static long roundToTens(double median) {
+    return Math.round(median/10)*10;
+  }
+
+  static String format(double median) {
+    return NumberFormat.getFormat("0").format(median);
+  }
+
+  static String outerHtml(Element e) {
+    String string = "<" + e.getNodeName() + ">"
+    + e.getInnerHTML()
+    + "</" + e.getNodeName() + ">";
+    return string;
+  }
+}
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestWidget.java Tue Jan 5 10:30:31 2010
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.google.gwt.reference.microbenchmark.client;
-
-import com.google.gwt.dom.client.DivElement;
-import com.google.gwt.dom.client.SpanElement;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HTMLPanel;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * Run by {...@link WidgetCreation}, see {...@link Maker#name} for details.
- */
-public class TestWidget extends Composite {
-  public static class Maker extends WidgetCreation.Maker {
-    Maker() {
-      super("Complex UI via typical manual HTMLPanel usage");
-    }
-    public Widget make() {
-      return new TestWidget();
-    }
-  }
-  DivElement div1;
-  DivElement div2;
-  DivElement div3;
-  DivElement div4;
-  SpanElement span1;
-
-
-  SpanElement span2;
-
-  private TestWidget() {
-    HTMLPanel p = new HTMLPanel(TestDom.HTML);
-    initWidget(p);
-
-    div1 = p.getElementById("div1").cast();
-    div2 = p.getElementById("div2").cast();
-    div3 = p.getElementById("div3").cast();
-    div4 = p.getElementById("div4").cast();
-    span1 = p.getElementById("span1").cast();
-    span2 = p.getElementById("span2").cast();
-  }
-}
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/Microbenchmarks.java Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/Microbenchmarks.java Thu Jan 7 14:15:09 2010
@@ -15,6 +15,7 @@
  */
 package com.google.gwt.reference.microbenchmark.client;

+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.dom.client.Element;
@@ -45,10 +46,12 @@
       new WidgetCreation()
   };

+  double elapsedMs = 0;
   @UiField ListBox listBox;
   @UiField DeckPanel deck;
   @UiField Button button;
   @UiField Element running;
+  @UiField Element elapsed;

   @UiHandler("listBox")
   public void onChange(@SuppressWarnings("unused") ChangeEvent ignored) {
@@ -63,9 +66,13 @@
     button.setEnabled(false);
     DeferredCommand.addCommand(new Command() {
       public void execute() {
+        double start = Duration.currentTimeMillis();
         benchmarks[index].run();
         UIObject.setVisible(running, false);
         button.setEnabled(true);
+        double end = Duration.currentTimeMillis();
+        elapsedMs += end - start;
+        elapsed.setInnerText(Util.format(elapsedMs));
       }
     });
   }
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/Microbenchmarks.ui.xml Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/Microbenchmarks.ui.xml Thu Jan 7 14:15:09 2010
@@ -5,6 +5,7 @@
     <div style='margin-left:1em; margin-top:1em;'>
       Select Benchmark: <gwt:ListBox ui:field='listBox'/>
       <gwt:Button ui:field='button'>Run</gwt:Button>
+      <span ui:field='elapsed'></span>
       <span style="display:none; color:gray; font-style:oblique"
         ui:field='running'>Running...</span>
     </div>
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestCursorDomCrawl.java Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestCursorDomCrawl.java Thu Jan 7 14:15:09 2010
@@ -11,7 +11,7 @@
 public class TestCursorDomCrawl extends Widget {
   public static class Maker extends WidgetCreation.Maker {
     Maker() {
- super("Complex UI via innerHTML, no widgets, get children by idealized crawl"); + super("Text heavy UI via innerHTML, no widgets, get children by idealized crawl");
     }
     public Widget make() {
       return new TestCursorDomCrawl();
@@ -27,7 +27,7 @@
   SpanElement span2;

   private TestCursorDomCrawl() {
-    Element root = TestDom.fromHtml(TestDom.HTML);
+    Element root = Util.fromHtml(Util.TEXTY_OUTER_HTML);

     Element cursor = root;
     div1 = (cursor = cursor.getFirstChildElement()).cast();
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDom.java Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDom.java Thu Jan 7 14:15:09 2010
@@ -27,35 +27,13 @@
 public class TestDom extends Widget {
   public static class Maker extends WidgetCreation.Maker {
     Maker() {
-      super("Complex UI via innerHTML, no widgets, get children by id");
+      super("Text heavy UI via innerHTML, no widgets, get children by id");
     }
     public Widget make() {
       return new TestDom();
     }
   }

-  static final String HTML = "<div>"
-    +   "<div id='div1'>"
-    +     "<div id='div2'></div>"
-    +     "<span id='span1'></span>"
-    +   "</div>"
-    +   "<div>"
-    +     "<div id='div3'>"
-    +       "<div id='div4'></div>"
-    +       "<span id='span2'></span>"
-    +     "</div>"
-    +   "</div>"
-    + "</div>";
-
- private static final DivElement detachedDiv = Document.get().createDivElement();
-
-  static Element fromHtml(String html) {
-    detachedDiv.setInnerHTML(html);
-    Element e = detachedDiv.getFirstChildElement();
-    e.getParentElement().removeChild(e);
-    return e;
-  }
-
   Element root;
   DivElement div1;
   DivElement div2;
@@ -67,7 +45,7 @@
   SpanElement span2;

   private TestDom() {
-    root = fromHtml(HTML);
+    root = Util.fromHtml(Util.TEXTY_OUTER_HTML);

     Document.get().getBody().appendChild(root);
     div1 = Document.get().getElementById("div1").cast();
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDomBinder.java Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDomBinder.java Thu Jan 7 14:15:09 2010
@@ -30,7 +30,7 @@

   public static class Maker extends WidgetCreation.Maker {
     Maker() {
-      super("Complex UI via UiBinder, no widgets");
+      super("Text heavy UI via UiBinder, no widgets");
     }
     public Widget make() {
       return new TestDomBinder();
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDomBinder.ui.xml Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestDomBinder.ui.xml Thu Jan 7 14:15:09 2010
@@ -1,16 +1,14 @@
 <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'>
-      <div>
-        <div ui:field='div1'>
-          <div ui:field='div2'>
-          </div>
-          <span ui:field='span1'/>
-        </div>
-        <div>
-        <div ui:field='div3'>
-          <div ui:field='div4'>
-          </div>
-          <span ui:field='span2'/>
-        </div>
-      </div>
-      </div>
+  <div>Div root start
+    <div ui:field='div1'>Div1
+      <div ui:field='div2'>Div2</div>
+      <span ui:field='span1'>Span1</span>
+    Div1 end</div>
+    <div>Div anon start
+      <div ui:field='div3'>Div3
+        <div ui:field='div4'>Div4</div>
+        <span ui:field='span2'>Span2</span>
+      Div3 end</div>
+    Div anon end</div>
+  Div root end</div>
 </ui:UiBinder>
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestFlows.java Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestFlows.java Thu Jan 7 14:15:09 2010
@@ -2,7 +2,7 @@

 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.InlineLabel;
 import com.google.gwt.user.client.ui.Widget;

 /**
@@ -11,7 +11,7 @@
 public class TestFlows extends Composite {
   public static class Maker extends WidgetCreation.Maker {
     Maker() {
-      super("Complex UI via FlowPanels (DIVs) and Labels (SPANs)");
+ super("Text heavy UI via FlowPanels (DIVs) and InlineLabels (SPANs)");
     }
     public Widget make() {
       return new TestFlows();
@@ -20,23 +20,41 @@

   private TestFlows() {
     FlowPanel root = new FlowPanel();
+    Util.addText(root.getElement(), "Div root");
+
     FlowPanel div1 = new FlowPanel();
+    Util.addText(div1.getElement(), "Div1");
+    root.add(div1);
+
     FlowPanel div2 = new FlowPanel();
-    FlowPanel child2 = new FlowPanel();
-    FlowPanel div3 = new FlowPanel();
-    FlowPanel div4 = new FlowPanel();
-    Label span1 = new Label();
-    Label span2 = new Label();
-
+    Util.addText(div2.getElement(), "Div2");
     div1.add(div2);
+
+    InlineLabel span1 = new InlineLabel();
+    span1.setText("Span1");
     div1.add(span1);
-    root.add(div1);
-
-    child2.add(div3);
+
+    FlowPanel anon = new FlowPanel();
+    Util.addText(anon.getElement(), "Div anon");
+    root.add(anon);
+
+    FlowPanel div3 = new FlowPanel();
+    Util.addText(div3.getElement(), "Div3");
+    anon.add(div3);
+
+    FlowPanel div4 = new FlowPanel();
+    Util.addText(div4.getElement(), "Div4");
     div3.add(div4);
+
+    InlineLabel span2 = new InlineLabel();
+    span2.setText("Span2");
     div3.add(span2);
-    root.add(child2);
-
+
+    Util.addText(div1.getElement(), " Div1 end");
+    Util.addText(div3.getElement(), " Div3 end");
+    Util.addText(anon.getElement(), " Div anon end");
+    Util.addText(root.getElement(), " Div root end");
+
     initWidget(root);
   }
 }
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestRealisticDomCrawl.java Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestRealisticDomCrawl.java Thu Jan 7 14:15:09 2010
@@ -11,7 +11,7 @@
 public class TestRealisticDomCrawl extends Widget {
   public static class Maker extends WidgetCreation.Maker {
     Maker() {
- super("Complex UI via innerHTML, no widgets, get children by nav from root"); + super("Text heavy UI via innerHTML, no widgets, get children by nav from root");
     }
     public Widget make() {
       return new TestRealisticDomCrawl();
@@ -28,7 +28,7 @@
   SpanElement span2;

   private TestRealisticDomCrawl() {
-    Element root = TestDom.fromHtml(TestDom.HTML);
+    Element root = Util.fromHtml(Util.TEXTY_OUTER_HTML);

     div1 = root.getFirstChildElement().cast();
     assert div1.getId().equals("div1");
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestWidgetBinder.java Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestWidgetBinder.java Thu Jan 7 14:15:09 2010
@@ -29,7 +29,7 @@
 public class TestWidgetBinder extends Composite {
   public static class Maker extends WidgetCreation.Maker {
     Maker() {
-      super("Complex UI with HTMLPanel via UiBinder");
+      super("Text heavy UI with HTMLPanel via UiBinder");
     }
     public Widget make() {
       return new TestWidgetBinder();
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestWidgetBinder.ui.xml Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/TestWidgetBinder.ui.xml Thu Jan 7 14:15:09 2010
@@ -1,19 +1,15 @@
 <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
   xmlns:gwt='urn:import:com.google.gwt.user.client.ui'>
-  <gwt:HTMLPanel>
-    <div>
-      <div ui:field='div1'>
-        <div ui:field='div2'>
-        </div>
-        <span ui:field='span1' />
-      </div>
-      <div>
-        <div ui:field='div3'>
-          <div ui:field='div4'>
-          </div>
-          <span ui:field='span2' />
-        </div>
-      </div>
-    </div>
-  </gwt:HTMLPanel>
+  <gwt:HTMLPanel>Div root start
+    <div ui:field='div1'>Div1
+      <div ui:field='div2'>Div2</div>
+      <span ui:field='span1'>Span1</span>
+    Div1 end</div>
+    <div>Div anon start
+      <div ui:field='div3'>Div3
+        <div ui:field='div4'>Div4</div>
+        <span ui:field='span2'>Span2</span>
+      Div3 end</div>
+    Div anon end</div>
+  Div root end</gwt:HTMLPanel>
 </ui:UiBinder>
=======================================
--- /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/WidgetCreation.java Tue Jan 5 10:30:31 2010 +++ /trunk/reference/Microbenchmarks/src/com/google/gwt/reference/microbenchmark/client/WidgetCreation.java Thu Jan 7 14:15:09 2010
@@ -19,7 +19,6 @@
 import com.google.gwt.dom.client.Document;
 import com.google.gwt.event.dom.client.BlurEvent;
 import com.google.gwt.event.dom.client.BlurHandler;
-import com.google.gwt.i18n.client.NumberFormat;
 import com.google.gwt.user.client.Cookies;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.Window.ClosingEvent;
@@ -27,6 +26,7 @@
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Grid;
 import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.InlineLabel;
 import com.google.gwt.user.client.ui.RootPanel;
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.TextBox;
@@ -75,9 +75,13 @@
         public Widget make() {
           return new HTMLPanel("");
         }
-      }, new EmptyBinder.Maker(), new TestDom.Maker(),
-      new TestCursorDomCrawl.Maker(), new TestRealisticDomCrawl.Maker(),
- new TestDomBinder.Maker(), new TestFlows.Maker(), new TestWidget.Maker(),
+      }, new EmptyBinder.Maker(), new TestEmptyDomViaApi.Maker(),
+      new TestEmptyDom.Maker(),
+      new TestEmptyCursorDomCrawl.Maker(),
+      new TestEmptyRealisticDomCrawl.Maker(),new TestDomViaApi.Maker(),
+      new TestDom.Maker(), new TestCursorDomCrawl.Maker(),
+      new TestRealisticDomCrawl.Maker(), new TestDomBinder.Maker(),
+      new TestFlows.Maker(), new TestManualHTMLPanel.Maker(),
       new TestWidgetBinder.Maker()};

   final private FlowPanel root;
@@ -112,7 +116,10 @@
     for (Maker m : makers) {
       grid.setText(row, 0, "0");
       grid.setText(row, 1, "0");
-      grid.setText(row, 2, m.name);
+      InlineLabel a = new InlineLabel();
+      a.setText(m.name);
+      a.setTitle(Util.outerHtml(m.make().getElement()));
+      grid.setWidget(row, 2, a);
       row++;
     }

@@ -169,10 +176,6 @@
       row++;
     }
   }
-
-  private String format(double median) {
-    return NumberFormat.getFormat("0").format(median);
-  }

   private int getInstances() {
     try {
@@ -185,7 +188,7 @@

   private void record(int row, double thisTime) {
     final int columns = grid.getColumnCount();
-    grid.setText(row, columns - 1, format(thisTime));
+    grid.setText(row, columns - 1, Util.format(thisTime));

     double max = 0, min = 0, mean = 0;

@@ -203,10 +206,10 @@
     double range = max - min;
     double halfRange = range / 2;
     double median = min + halfRange;
-    grid.setText(row, 0, format(median));
+    grid.setText(row, 0, Util.format(Util.roundToTens(median)));

     mean = mean / (columns - 3);
-    grid.setText(row, 1, format(mean));
+    grid.setText(row, 1, Util.format(Util.roundToTens(mean)));
   }

   @SuppressWarnings("deprecation")
-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to