Removes "Profile" code.
Looks likes another attempt for benchmarking in GWT SDK.
Change-Id: If841b8ca4dc6fdc598e5c4cc04dc35ac274b32e4
Review-Link: https://gwt-review.googlesource.com/#/c/2000/
Review by: skybrian@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@11526 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/test/com/google/gwt/emultest/java/util/StackProfile.java b/user/test/com/google/gwt/emultest/java/util/StackProfile.java
deleted file mode 100644
index e755168..0000000
--- a/user/test/com/google/gwt/emultest/java/util/StackProfile.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2007 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.emultest.java.util;
-
-import com.google.gwt.user.client.ui.WidgetProfile;
-
-import java.util.Stack;
-
-/**
- * TODO: document me.
- */
-public class StackProfile extends WidgetProfile {
-
- /**
- * Sets module name so that javascript compiler can operate.
- */
- public String getModuleName() {
- return "com.google.gwt.emultest.EmulSuite";
- }
-
- public void testTiming() throws Exception {
- int t = 1;
- while (true) {
- testTiming(t);
- t = t * 2;
- }
- // throw new Exception("Finished profiling");
- }
-
- public void testTiming(int i) {
- addTiming(i);
- }
-
- public void addTiming(int num) {
- Stack<String> s = new Stack<String>();
- resetTimer();
- for (int i = 0; i < num; i++) {
- s.push("item" + i);
- }
- timing("push(" + num + ")");
- resetTimer();
- for (int i = 0; i < num; i++) {
- s.pop();
- }
- timing("pop(" + num + ")");
- }
-}
diff --git a/user/test/com/google/gwt/user/client/Profile.java b/user/test/com/google/gwt/user/client/Profile.java
deleted file mode 100644
index 7b4bfcb..0000000
--- a/user/test/com/google/gwt/user/client/Profile.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2007 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.user.client;
-
-import com.google.gwt.core.client.Duration;
-import com.google.gwt.junit.client.GWTTestCase;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.RootPanel;
-
-/**
- * TODO: document me.
- */
-public abstract class Profile extends GWTTestCase {
-
- /**
- * An enumeration defining the possible report types.
- */
- public enum ReportType {
- REPORT_TO_BROWSER, REPORT_TO_EXCEL, REPORT_TO_WIKI
- }
-
- private static String browser;
- private static ReportType reportType = ReportType.REPORT_TO_WIKI;
- private static double time;
-
- public static void setReportType(ReportType type) {
- reportType = type;
- }
-
- private void browserTiming(String s) {
- double elapsed = Duration.currentTimeMillis() - time;
- RootPanel.get().add(
- new Label("|" + browser + "|" + s + "|" + elapsed + " milliseconds|"));
- }
-
- protected void resetTimer() {
- time = Duration.currentTimeMillis();
- if (browser == null) {
- browser = getBrowser();
- }
- }
-
- protected void timing(String s) {
- double elapsed = Duration.currentTimeMillis() - time;
- switch (reportType) {
- case REPORT_TO_BROWSER:
- browserTiming(s);
- break;
- case REPORT_TO_WIKI:
- this.addCheckpoint("|" + browser + "|" + s + "|" + elapsed
- + " milliseconds|");
- break;
- case REPORT_TO_EXCEL:
- s = s.replace('|', '\t');
- this.addCheckpoint(browser + "\t" + s + "\t" + elapsed);
- break;
- default:
- throw new IllegalStateException("Should not ever get here");
- }
- }
-
- public native String getBrowser() /*-{
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf("opera") != -1) {
- return "opera";
- }
- else if (ua.indexOf("safari") != -1) {
- return "safari";
- }
- else if ((ua.indexOf("msie 6.0") != -1) ||
- (ua.indexOf("msie 7.0") != -1)) {
- return "ie6";
- }
- else if (ua.indexOf("gecko") != -1) {
- return "gecko1_8";
- }
- return "unknown";
- }-*/;
-}
diff --git a/user/test/com/google/gwt/user/client/ui/FastStringMapProfile.java b/user/test/com/google/gwt/user/client/ui/FastStringMapProfile.java
deleted file mode 100644
index 71f50b1..0000000
--- a/user/test/com/google/gwt/user/client/ui/FastStringMapProfile.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2007 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.user.client.ui;
-
-import java.util.Map;
-
-/**
- * TODO: document me.
- */
-public class FastStringMapProfile extends WidgetProfile {
-
- Map<String, Integer> m;
-
- public void testTiming() throws Exception {
- m = putTiming(32000);
- timing(2000);
- timing(4000);
- timing(8000);
- timing(16000);
- timing(32000);
- throw new Exception("|browser|test case|time|");
- }
-
- private void timing(int s) {
- getTiming(s);
- }
-
- public void getTiming(int size) {
- this.resetTimer();
- for (int i = 0; i < size; i++) {
- m.get(size + ":");
- }
- this.timing("get(" + size + ")");
- }
-
- public FastStringMap<Integer> putTiming(int size) {
- FastStringMap<Integer> m1 = new FastStringMap<Integer>();
- this.resetTimer();
- for (int i = 0; i < size; i++) {
- Integer iVal = new Integer(size);
- m1.put(iVal.hashCode() + "", iVal);
- }
- this.timing("put(" + size + ")");
- return m1;
- }
-
- public int instanceOfTiming() {
- int count = 0;
- int size = 20000;
- Object a = new String();
-
- this.resetTimer();
- for (int i = 0; i < size; i++) {
- if (a instanceof String) {
- ++count;
- }
- }
- this.timing("instanceOf(" + size + "," + a + ")");
- return count;
- }
-}
diff --git a/user/test/com/google/gwt/user/client/ui/FlexTableProfile.java b/user/test/com/google/gwt/user/client/ui/FlexTableProfile.java
deleted file mode 100644
index ce9554e..0000000
--- a/user/test/com/google/gwt/user/client/ui/FlexTableProfile.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2007 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.user.client.ui;
-
-/**
- * TODO: document me.
- */
-public class FlexTableProfile extends HTMLTableProfile {
-
- public HTMLTable createTable(int rows, int columns) {
- return new FlexTable();
- }
-
-}
diff --git a/user/test/com/google/gwt/user/client/ui/GridProfile.java b/user/test/com/google/gwt/user/client/ui/GridProfile.java
deleted file mode 100644
index 56e2d73..0000000
--- a/user/test/com/google/gwt/user/client/ui/GridProfile.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2007 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.user.client.ui;
-
-/**
- * TODO: document me.
- */
-public class GridProfile extends HTMLTableProfile {
- public HTMLTable createTable(int rows, int columns) {
- return new Grid(rows, columns);
- }
-}
diff --git a/user/test/com/google/gwt/user/client/ui/HTMLTableProfile.java b/user/test/com/google/gwt/user/client/ui/HTMLTableProfile.java
deleted file mode 100644
index cc86737..0000000
--- a/user/test/com/google/gwt/user/client/ui/HTMLTableProfile.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2007 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.user.client.ui;
-
-import com.google.gwt.user.client.ui.HTMLTable.ColumnFormatter;
-
-import java.util.HashMap;
-
-/**
- * TODO: document me.
- */
-public abstract class HTMLTableProfile extends WidgetProfile {
-
- public abstract HTMLTable createTable(int rows, int columns);
-
- public void addStyleName(int rows, int columns) {
- HTMLTable HTMLTable = createTable(rows, columns);
- resetTimer();
- for (int row = 0; row < rows; row++) {
- for (int column = 0; column < columns; column++) {
- HTMLTable.getCellFormatter().addStyleName(row, column, "foo");
- }
- }
- timing("addStyleName(" + rows + "," + columns + ")");
- }
-
- public void setStyleName(int rows, int columns) {
- System.out.println("Hybrid mode");
- HTMLTable HTMLTable = createTable(rows, columns);
- resetTimer();
- for (int row = 0; row < rows; row++) {
- for (int column = 0; column < columns; column++) {
- HTMLTable.getCellFormatter().setStyleName(row, column,
- row + "," + column);
- }
- }
- timing("setStyleName(" + rows + "," + columns + ")");
- }
-
- public void createTableTiming(int rows, int columns) {
- resetTimer();
- createTable(rows, columns);
- timing("createTable(" + rows + "," + columns + ")");
- }
-
- public void getStyleName(int rows, int columns) {
- System.out.println("Hybrid mode");
- HTMLTable HTMLTable = createTable(rows, columns);
- resetTimer();
- for (int row = 0; row < rows; row++) {
- for (int column = 0; column < columns; column++) {
- HTMLTable.getCellFormatter().getStyleName(row, column);
- }
- }
- timing("getStyleName(" + rows + "," + columns + ")");
- }
-
- public void hashMapShare(int rows, int columns) {
- resetTimer();
- HashMap<String, Label> m = new HashMap<String, Label>();
- for (int row = 0; row < rows; row++) {
- for (int column = 0; column < columns; column++) {
- Label label = new Label(column + "i");
- m.put(row + "," + column, label);
- }
- }
- timing("hashMapShare(" + rows + "," + columns + ")");
- }
-
- public void setHTMLTiming(int rows, int columns) {
- resetTimer();
- HTMLTable HTMLTable = createTable(rows, columns);
- for (int row = 0; row < rows; row++) {
- for (int column = 0; column < columns; column++) {
- HTMLTable.setHTML(row, column, "test");
- }
- }
- timing("setHTML(" + rows + "," + columns + ")");
- }
-
- public void setTextTiming(int rows, int columns) {
- resetTimer();
- HTMLTable HTMLTable = createTable(rows, columns);
- for (int row = 0; row < rows; row++) {
- for (int column = 0; column < columns; column++) {
- HTMLTable.setText(row, column, "test");
- }
- }
- timing(" setText(" + rows + "," + columns + ")");
- }
-
- public void setWidgetTiming(int rows, int columns) {
- resetTimer();
- HTMLTable HTMLTable = createTable(rows, columns);
- RootPanel.get().add(HTMLTable);
- for (int row = 0; row < rows; row++) {
- for (int column = 0; column < columns; column++) {
- Label label = new Label(column + "i");
- HTMLTable.setWidget(row, column, label);
- }
- }
- timing("setWidgetTiming(" + rows + "," + columns + ")");
- }
-
- public void columnAddStyleName(int rows, int cols) {
- HTMLTable table = createTable(rows, cols);
- resetTimer();
- ColumnFormatter formatter = table.getColumnFormatter();
- for (int i = 0; i < cols; i++) {
- formatter.addStyleName(i, "fooStyle");
- }
- timing("column.addStyleName(" + rows + ", " + cols + ")");
- }
-
- public void testTimings() throws Exception {
- timing(10, 10);
- timing(20, 10);
- timing(20, 20);
- timing(40, 20);
- timing(40, 40);
- timing(80, 40);
- timing(80, 80);
-
- throw new Exception("Finished Profile");
- }
-
- public void timing(int rows, int columns) {
- columnAddStyleName(rows, columns);
- }
-
-}
diff --git a/user/test/com/google/gwt/user/client/ui/ListBoxProfile.java b/user/test/com/google/gwt/user/client/ui/ListBoxProfile.java
deleted file mode 100644
index b21041e..0000000
--- a/user/test/com/google/gwt/user/client/ui/ListBoxProfile.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2007 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.user.client.ui;
-
-/**
- * TODO: document me.
- */
-public class ListBoxProfile extends WidgetProfile {
-
- public void testTiming() throws Exception {
- testTiming(1);
- testTiming(2);
- testTiming(4);
- testTiming(8);
- testTiming(16);
- testTiming(32);
- testTiming(64);
- testTiming(128);
- testTiming(256);
- testTiming(512);
- testTiming(1024);
-
- throw new Exception("Finished profiling");
- }
-
- public void testTiming(int i) {
- addTiming(i);
- }
-
- public void addTiming(int num) {
- ListBox b = new ListBox();
- RootPanel.get().add(b);
- resetTimer();
- for (int i = 0; i < num; i++) {
- // CHECKSTYLE_OFF
- b.addItem("item" + i, "i:" + i);
- // CHECKSTYLE_ON
- }
- timing("add(" + num + ")");
- }
-}
diff --git a/user/test/com/google/gwt/user/client/ui/TreeProfile.java b/user/test/com/google/gwt/user/client/ui/TreeProfile.java
deleted file mode 100644
index 0c871d8..0000000
--- a/user/test/com/google/gwt/user/client/ui/TreeProfile.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2007 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.user.client.ui;
-
-import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.Window;
-
-/**
- * TODO: document me.
- */
-public class TreeProfile extends WidgetProfile {
-
- // Using 10*10,20*10,20*20,40*20, 40*40, 80*40,80*80 to get answers. 40*20 and
- // 80*40
- // breaks the square pattern because the closest squares are a bit too far off
- public void testTiming() throws Exception {
-
- int[] flatTree = {50};
- timing(flatTree);
-
- flatTree[0] = 100;
- timing(flatTree);
- flatTree[0] = 200;
- timing(flatTree);
- flatTree[0] = 400;
- timing(flatTree);
- flatTree[0] = 800;
- timing(flatTree);
-
- int[] bushy = {2, 2, 2, 2};
- timing(bushy);
- int[] bushy2 = {2, 2, 2, 2, 2};
- timing(bushy2);
- int[] bushy3 = {2, 2, 2, 2, 2, 2};
- timing(bushy3);
- int[] bushy4 = {2, 2, 2, 2, 2, 2, 2};
- timing(bushy4);
- int[] bushy5 = {2, 2, 2, 2, 2, 2, 2, 2};
- timing(bushy5);
- int[] bushy6 = {2, 2, 2, 2, 2, 2, 2, 2, 2};
- timing(bushy6);
- int[] bushy7 = {2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
- timing(bushy7);
- throw new Exception("Finished Profile");
- }
-
- public void tastMemory() throws Exception {
- int[] flatTree = {100};
- for (int i = 0; i < 30; i++) {
- timing(flatTree);
- Window.alert("forcing event pump");
- }
- throw new Exception("Finished Profile");
- }
-
- static int run = 0;
-
- public void timing(final int[] branches) {
- Timer t = new Timer() {
- public void run() {
- ++run;
- }
- };
- createTree(branches);
- }
-
- Tree createTree(int[] branches) {
- String branchName = "[";
- for (int i = 0; i < branches.length; i++) {
- if (i != 0) {
- branchName += ", ";
- }
- branchName += branches[i];
- }
- branchName = "Created tree with branches " + branchName + "]";
- resetTimer();
- Tree t = new Tree();
- RootPanel.get().add(t);
- for (int i = 0; i < branches[0]; i++) {
- TreeItem item = new TreeItem(branches[0] + "-" + i);
- t.addItem(item);
- if (branches.length > 1) {
- createTreeItem(item, branches, 1);
- }
- }
- timing(branchName);
- return t;
- }
-
- void createTreeItem(TreeItem branch, int[] branches, int marker) {
- for (int i = 0; i < branches[marker]; i++) {
- TreeItem child = new TreeItem();
- child.setText(branches[marker] + "-" + i);
- branch.addItem(child);
- if (marker + 1 < branches.length) {
- createTreeItem(child, branches, marker + 1);
- }
- }
- }
-
- Tree createCheckBoxTree(int[] branches) {
- String branchName = "[";
- for (int i = 0; i < branches.length; i++) {
- if (i != 0) {
- branchName += ", ";
- }
- branchName += branches[i];
- }
- branchName = "Created checkbox tree with branches " + branchName + "]";
- resetTimer();
- Tree t = new Tree();
- RootPanel.get().add(t);
- for (int i = 0; i < branches[0]; i++) {
- TreeItem item = new TreeItem(branches[0] + "-" + i);
- t.addItem(item);
- if (branches.length > 1) {
- createCheckBoxTreeItem(item, branches, 1);
- }
- }
- timing(branchName);
- return t;
- }
-
- void createCheckBoxTreeItem(TreeItem branch, int[] branches, int marker) {
- for (int i = 0; i < branches[marker]; i++) {
- TreeItem child = new TreeItem(new CheckBox(branches[marker] + "-" + i));
- branch.addItem(child);
- if (marker + 1 < branches.length) {
- createLabelTreeItem(child, branches, marker + 1);
- }
- }
- }
-
- Tree createLabelTree(int[] branches) {
- String branchName = "[";
- for (int i = 0; i < branches.length; i++) {
- if (i != 0) {
- branchName += ", ";
- }
- branchName += branches[i];
- }
- branchName = "Created label tree with branches " + branchName + "]";
- resetTimer();
- Tree t = new Tree();
- RootPanel.get().add(t);
- for (int i = 0; i < branches[0]; i++) {
- TreeItem item = new TreeItem(new Label(branches[0] + "-" + i));
- t.addItem(item);
- if (branches.length > 1) {
-
- createLabelTreeItem(item, branches, 1);
- }
- }
- timing(branchName);
- return t;
- }
-
- void createLabelTreeItem(TreeItem branch, int[] branches, int marker) {
- for (int i = 0; i < branches[marker]; i++) {
- TreeItem child = new TreeItem(new Label(branches[marker] + "-" + i));
- branch.addItem(child);
- if (marker + 1 < branches.length) {
- createLabelTreeItem(child, branches, marker + 1);
- }
- }
- }
-}
diff --git a/user/test/com/google/gwt/user/client/ui/WidgetProfile.java b/user/test/com/google/gwt/user/client/ui/WidgetProfile.java
deleted file mode 100644
index d2cb7b0..0000000
--- a/user/test/com/google/gwt/user/client/ui/WidgetProfile.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2007 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.user.client.ui;
-
-import com.google.gwt.user.client.Profile;
-
-/**
- * TODO: document me.
- */
-public abstract class WidgetProfile extends Profile {
-
- public String getModuleName() {
- return "com.google.gwt.user.User";
- }
-}