- Moved benchmark viewer out of the junit package and into its own
- Also did Java 1.5 source cleanup on benchmark viewer
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1930 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/distro-source/linux/src/benchmarkViewer b/distro-source/linux/src/benchmarkViewer
index 1735d0a..7b308d7 100755
--- a/distro-source/linux/src/benchmarkViewer
+++ b/distro-source/linux/src/benchmarkViewer
@@ -1,3 +1,3 @@
#!/bin/sh
APPDIR=`dirname $0`;
-java -Dcom.google.gwt.junit.reportPath="$1" -cp "$APPDIR/gwt-user.jar:$APPDIR/gwt-dev-linux.jar:$APPDIR/gwt-benchmark-viewer.jar" com.google.gwt.dev.GWTShell -port auto com.google.gwt.junit.viewer.ReportViewer/ReportViewer.html?gwt.hybrid;
+java -Dcom.google.gwt.junit.reportPath="$1" -cp "$APPDIR/gwt-user.jar:$APPDIR/gwt-dev-linux.jar:$APPDIR/gwt-benchmark-viewer.jar" com.google.gwt.dev.GWTShell -port auto com.google.gwt.benchmarks.viewer.ReportViewer/ReportViewer.html?gwt.hybrid;
diff --git a/distro-source/mac/src/benchmarkViewer b/distro-source/mac/src/benchmarkViewer
index e6dd9a6..acf4b22 100755
--- a/distro-source/mac/src/benchmarkViewer
+++ b/distro-source/mac/src/benchmarkViewer
@@ -1,3 +1,3 @@
#!/bin/sh
APPDIR=`dirname $0`;
-java -Dcom.google.gwt.junit.reportPath="$1" -XstartOnFirstThread -cp "$APPDIR/gwt-user.jar:$APPDIR/gwt-dev-mac.jar:$APPDIR/gwt-benchmark-viewer.jar" com.google.gwt.dev.GWTShell -port auto com.google.gwt.junit.viewer.ReportViewer/ReportViewer.html?gwt.hybrid;
+java -Dcom.google.gwt.junit.reportPath="$1" -XstartOnFirstThread -cp "$APPDIR/gwt-user.jar:$APPDIR/gwt-dev-mac.jar:$APPDIR/gwt-benchmark-viewer.jar" com.google.gwt.dev.GWTShell -port auto com.google.gwt.benchmarks.viewer.ReportViewer/ReportViewer.html?gwt.hybrid;
diff --git a/distro-source/windows/src/benchmarkViewer.cmd b/distro-source/windows/src/benchmarkViewer.cmd
index 28ae3b7..bddc9d9 100755
--- a/distro-source/windows/src/benchmarkViewer.cmd
+++ b/distro-source/windows/src/benchmarkViewer.cmd
@@ -1 +1 @@
-@java -Dcom.google.gwt.junit.reportPath="%1" -cp "%~dp0/gwt-user.jar;%~dp0/gwt-dev-windows.jar;%~dp0/gwt-benchmark-viewer.jar" com.google.gwt.dev.GWTShell -port auto com.google.gwt.junit.viewer.ReportViewer/ReportViewer.html?gwt.hybrid;
+@java -Dcom.google.gwt.junit.reportPath="%1" -cp "%~dp0/gwt-user.jar;%~dp0/gwt-dev-windows.jar;%~dp0/gwt-benchmark-viewer.jar" com.google.gwt.dev.GWTShell -port auto com.google.gwt.benchmarks.viewer.ReportViewer/ReportViewer.html?gwt.hybrid;
diff --git a/tools/benchmark-viewer/build.xml b/tools/benchmark-viewer/build.xml
index 431f444..bf460e9 100755
--- a/tools/benchmark-viewer/build.xml
+++ b/tools/benchmark-viewer/build.xml
@@ -15,8 +15,8 @@
<import file="${gwt.root}/common.ant.xml" />
<property name="tools.build" value="${gwt.build.out}/${project.tail}" />
- <property name="tools.module" value="com.google.gwt.junit.viewer.ReportViewer" />
- <property name="tools.module.path" value="com/google/gwt/junit/viewer/public" />
+ <property name="tools.module" value="com.google.gwt.benchmarks.viewer.ReportViewer" />
+ <property name="tools.module.path" value="com/google/gwt/benchmarks/viewer/public" />
<!--
Default hosted mode test cases
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/ReportViewer.gwt.xml b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/ReportViewer.gwt.xml
similarity index 83%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/ReportViewer.gwt.xml
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/ReportViewer.gwt.xml
index 3017acf..96ab3a2 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/ReportViewer.gwt.xml
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/ReportViewer.gwt.xml
@@ -20,10 +20,10 @@
<source path="client"/>
- <entry-point class="com.google.gwt.junit.viewer.client.ReportViewer"/>
+ <entry-point class="com.google.gwt.benchmarks.viewer.client.ReportViewer"/>
- <servlet path='/test_reports' class='com.google.gwt.junit.viewer.server.ReportServerImpl'/>
- <servlet path='/test_images' class='com.google.gwt.junit.viewer.server.ReportImageServer'/>
+ <servlet path='/test_reports' class='com.google.gwt.benchmarks.viewer.server.ReportServerImpl'/>
+ <servlet path='/test_images' class='com.google.gwt.benchmarks.viewer.server.ReportImageServer'/>
<stylesheet src="ReportViewer.css"/>
</module>
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Benchmark.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Benchmark.java
similarity index 84%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Benchmark.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Benchmark.java
index d150928..421ad8a 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Benchmark.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Benchmark.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
import com.google.gwt.user.client.rpc.IsSerializable;
@@ -30,10 +30,7 @@
private String name;
- /**
- * @gwt.typeArgs <com.google.gwt.junit.viewer.client.Result>
- */
- private List/* <Result> */results;
+ private List<Result> results;
private String sourceCode;
@@ -49,7 +46,7 @@
return name;
}
- public List/* <Result> */getResults() {
+ public List<Result> getResults() {
return results;
}
@@ -69,7 +66,7 @@
this.name = name;
}
- public void setResults(List results) {
+ public void setResults(List<Result> results) {
this.results = results;
}
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/BrowserInfo.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/BrowserInfo.java
similarity index 98%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/BrowserInfo.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/BrowserInfo.java
index dd627f5..33bbe91 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/BrowserInfo.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/BrowserInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
/**
* Provides information about a browser (vendor,version,operating system,etc...)
@@ -39,6 +39,7 @@
* @return A pretty-printed version of the browser including the a) vendor b)
* version c) and operating system
*/
+ @SuppressWarnings("unused")
public static String getBrowser(String userAgent) {
userAgent = userAgent.toLowerCase();
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Category.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Category.java
similarity index 81%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Category.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Category.java
index 8b94ae9..2748aff 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Category.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Category.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
import com.google.gwt.user.client.rpc.IsSerializable;
@@ -24,16 +24,13 @@
*/
public class Category implements IsSerializable {
- /**
- * @gwt.typeArgs <com.google.gwt.junit.viewer.client.Benchmark>
- */
- private List benchmarks;
+ private List<Benchmark> benchmarks;
private String description;
private String name;
- public List getBenchmarks() {
+ public List<Benchmark> getBenchmarks() {
return benchmarks;
}
@@ -45,7 +42,7 @@
return name;
}
- public void setBenchmarks(List benchmarks) {
+ public void setBenchmarks(List<Benchmark> benchmarks) {
this.benchmarks = benchmarks;
}
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Report.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Report.java
similarity index 78%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Report.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Report.java
index 187bbfc..b179ab4 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Report.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Report.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
import com.google.gwt.user.client.rpc.IsSerializable;
@@ -25,21 +25,19 @@
*/
public class Report implements IsSerializable {
- /**
- * @gwt.typeArgs <com.google.gwt.junit.viewer.client.Category>
- */
- private List/* <Category> */categories;
+ private List<Category> categories;
private Date date;
- private String dateString; // Temporary addition until we get better date
+ // Temporary addition until we get better date
+ private String dateString;
// formatting in GWT
private String gwtVersion;
private String id;
- public List/* <Category> */getCategories() {
+ public List<Category> getCategories() {
return categories;
}
@@ -64,15 +62,15 @@
boolean testsPassed = true;
for (int i = 0; i < categories.size(); ++i) {
- Category c = (Category) categories.get(i);
- List benchmarks = c.getBenchmarks();
+ Category c = categories.get(i);
+ List<Benchmark> benchmarks = c.getBenchmarks();
numTests += benchmarks.size();
}
return new ReportSummary(id, date, dateString, numTests, testsPassed);
}
- public void setCategories(List categories) {
+ public void setCategories(List<Category> categories) {
this.categories = categories;
}
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportServer.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportServer.java
similarity index 86%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportServer.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportServer.java
index f21fe6f..74f554b 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportServer.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportServer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
import com.google.gwt.user.client.rpc.RemoteService;
@@ -40,8 +40,6 @@
* Returns a list of summaries of all the Benchmark reports.
*
* @return a non-null list of ReportSummary
- *
- * @gwt.typeArgs <com.google.gwt.junit.viewer.client.ReportSummary>
*/
- public List/* <ReportSummary> */getReportSummaries();
+ public List<ReportSummary> getReportSummaries();
}
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportServerAsync.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportServerAsync.java
similarity index 74%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportServerAsync.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportServerAsync.java
index e669e19..03d7bac 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportServerAsync.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportServerAsync.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,10 +13,12 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import java.util.List;
+
/**
* The asynchronous interface for ReportServer.
*
@@ -24,7 +26,7 @@
*/
public interface ReportServerAsync {
- public void getReport(String reportId, AsyncCallback callback);
+ public void getReport(String reportId, AsyncCallback<Report> callback);
- public void getReportSummaries(AsyncCallback callback);
+ public void getReportSummaries(AsyncCallback<List<ReportSummary>> callback);
}
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportSummary.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportSummary.java
similarity index 94%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportSummary.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportSummary.java
index 889861e..2d944ed 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportSummary.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportSummary.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
import com.google.gwt.user.client.rpc.IsSerializable;
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportViewer.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportViewer.java
similarity index 83%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportViewer.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportViewer.java
index 6d9583b..d6e2bca 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/ReportViewer.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/ReportViewer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
@@ -60,7 +60,7 @@
*
* You can configure the location where ReportServer reads the benchmark reports
* from by setting the system property named in
- * {@link com.google.gwt.junit.client.Benchmark#REPORT_PATH}.
+ * {@link com.google.gwt.benchmarks.client.Benchmark#REPORT_PATH}.
*/
public class ReportViewer implements EntryPoint {
@@ -75,20 +75,20 @@
private class SummariesTableListener implements TableListener {
- private FlexTable summariesTable;
+ private final FlexTable mySummariesTable;
SummariesTableListener(FlexTable summariesTable) {
- this.summariesTable = summariesTable;
+ this.mySummariesTable = summariesTable;
}
public void onCellClicked(SourcesTableEvents sender, int row, int col) {
if (currentSelectedRow != -1) {
- summariesTable.getRowFormatter().removeStyleName(currentSelectedRow,
+ mySummariesTable.getRowFormatter().removeStyleName(currentSelectedRow,
"viewer-SelectedRow");
}
currentSelectedRow = row;
- summariesTable.getRowFormatter().addStyleName(row, "viewer-SelectedRow");
- ReportSummary summary = (ReportSummary) summaries.get(row - 1);
+ mySummariesTable.getRowFormatter().addStyleName(row, "viewer-SelectedRow");
+ ReportSummary summary = summaries.get(row - 1);
getReportDetails(summary.getId());
}
}
@@ -109,7 +109,7 @@
HTML statusLabel;
- List/* <ReportSummary> */summaries;
+ List<ReportSummary> summaries;
VerticalPanel summariesPanel;
@@ -128,23 +128,21 @@
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "test_reports");
reportServer = (ReportServerAsync) target;
- reportServer.getReportSummaries(new AsyncCallback() {
+ reportServer.getReportSummaries(new AsyncCallback<List<ReportSummary>>() {
public void onFailure(Throwable caught) {
String msg = "<p>" + caught.toString() + "</p>"
+ "<p>Is your path to the reports correct?</p>";
statusLabel.setHTML(msg);
}
- public void onSuccess(Object result) {
- summaries = (List/* <ReportSummary> */) result;
+ public void onSuccess(List<ReportSummary> result) {
+ summaries = result;
if (summaries != null) {
if (summaries.size() == 0) {
statusLabel.setText("There are no benchmark reports available in this folder.");
}
- Collections.sort(summaries, new Comparator() {
- public int compare(Object o1, Object o2) {
- ReportSummary r1 = (ReportSummary) o1;
- ReportSummary r2 = (ReportSummary) o2;
+ Collections.sort(summaries, new Comparator<ReportSummary>() {
+ public int compare(ReportSummary r1, ReportSummary r2) {
return r2.getDate().compareTo(r1.getDate()); // most recent first
}
});
@@ -178,16 +176,14 @@
// topTable.setWidget( 0, 0, tempReportTable );
int currentRow = 1;
- Collections.sort(report.getCategories(), new Comparator() {
- public int compare(Object o1, Object o2) {
- Category c1 = (Category) o1;
- Category c2 = (Category) o2;
+ Collections.sort(report.getCategories(), new Comparator<Category>() {
+ public int compare(Category c1, Category c2) {
return c1.getName().compareTo(c2.getName());
}
}); // Should be done once in the RPC
for (int i = 0; i < report.getCategories().size(); ++i) {
- Category c = (Category) report.getCategories().get(i);
+ Category c = report.getCategories().get(i);
if (!c.getName().equals("")) {
FlexTable categoryTable = new FlexTable();
@@ -204,16 +200,14 @@
topTable.setWidget(currentRow++, 0, categoryTable);
}
- Collections.sort(c.getBenchmarks(), new Comparator() {
- public int compare(Object o1, Object o2) {
- Benchmark b1 = (Benchmark) o1;
- Benchmark b2 = (Benchmark) o2;
+ Collections.sort(c.getBenchmarks(), new Comparator<Benchmark>() {
+ public int compare(Benchmark b1, Benchmark b2) {
return b1.getName().compareTo(b2.getName());
}
}); // Should be done once in the RPC
for (int j = 0; j < c.getBenchmarks().size(); ++j) {
- Benchmark benchmark = (Benchmark) c.getBenchmarks().get(j);
+ Benchmark benchmark = c.getBenchmarks().get(j);
FlexTable benchmarkTable = new FlexTable();
benchmarkTable.setBorderWidth(0);
@@ -258,19 +252,26 @@
FlexTable.FlexCellFormatter resultsFormatter = resultsTable.getFlexCellFormatter();
topTable.setWidget(currentRow++, 0, resultsTable);
- Collections.sort(benchmark.getResults(), new Comparator() {
- public int compare(Object o1, Object o2) {
- Result r1 = (Result) o1;
- Result r2 = (Result) o2;
+ Collections.sort(benchmark.getResults(), new Comparator<Result>() {
+ public int compare(Result r1, Result r2) {
return r1.getAgent().compareTo(r2.getAgent());
}
}); // Should be done once in the RPC
- final List trialsTables = new ArrayList();
+ final List<FlexTable> trialsTables = new ArrayList<FlexTable>();
- Result sampleResult = (Result) benchmark.getResults().get(0);
- Trial sampleTrial = (Trial) sampleResult.getTrials().get(0);
- int numVariables = sampleTrial.getVariables().size();
+ int numVariables = 0;
+ List<String> variableNames = null;
+ if (benchmark.getResults().size() > 0) {
+ Result sampleResult = benchmark.getResults().get(0);
+ if (sampleResult.getTrials().size() > 0) {
+ Trial sampleTrial = sampleResult.getTrials().get(0);
+ numVariables = sampleTrial.getVariables().size();
+ Map<String, String> variables = sampleTrial.getVariables();
+ variableNames = new ArrayList<String>(variables.keySet());
+ Collections.sort(variableNames);
+ }
+ }
final MutableBool isVisible = new MutableBool(numVariables > 2);
String buttonName = isVisible.value ? "Hide Data" : "Show Data";
@@ -278,7 +279,7 @@
public void onClick(Widget sender) {
isVisible.value = !isVisible.value;
for (int i = 0; i < trialsTables.size(); ++i) {
- Widget w = (Widget) trialsTables.get(i);
+ Widget w = trialsTables.get(i);
w.setVisible(isVisible.value);
}
String name = isVisible.value ? "Hide Data" : "Show Data";
@@ -287,8 +288,7 @@
});
for (int k = 0; k < benchmark.getResults().size(); ++k) {
- Result result = (Result) benchmark.getResults().get(k);
- List trials = result.getTrials();
+ Result result = benchmark.getResults().get(k);
// Currently only support graphs for results of 2 variables or less
if (numVariables <= 2) {
@@ -335,15 +335,9 @@
resultsTable.setWidget(2, k, trialsTable);
- int numTrials = trials.size();
-
- Map variables = sampleTrial.getVariables();
- List variableNames = new ArrayList(variables.keySet());
- Collections.sort(variableNames);
-
// Write out the variable column headers
for (int varIndex = 0; varIndex < numVariables; ++varIndex) {
- String varName = (String) variableNames.get(varIndex);
+ String varName = variableNames.get(varIndex);
trialsTable.setHTML(0, varIndex, varName);
}
@@ -351,24 +345,23 @@
trialsTable.setHTML(0, numVariables, "Timing (ms)");
// Write out all the trial data
- for (int l = 0; l < numTrials; ++l) {
- Trial trial = (Trial) trials.get(l);
-
+ int l = 0;
+ for (Trial trial : result.getTrials()) {
// Write the variable values
for (int varIndex = 0; varIndex < numVariables; ++varIndex) {
- String varName = (String) variableNames.get(varIndex);
- String varValue = (String) trial.getVariables().get(varName);
+ String varName = variableNames.get(varIndex);
+ String varValue = trial.getVariables().get(varName);
trialsTable.setHTML(l + 1, varIndex, varValue);
}
// Write out the timing data
- String data = null;
- if (trial.getException() != null) {
- data = trial.getException();
- } else {
- data = trial.getRunTimeMillis() + "";
- }
+ String data = trial.getRunTimeMillis() + "";
trialsTable.setHTML(l + 1, numVariables, data);
+ ++l;
+ }
+
+ if (result.getException() != null) {
+ trialsTable.setHTML(l + 1, numVariables, result.getException());
}
}
}
@@ -396,7 +389,7 @@
}
for (int i = 0; i < summaries.size(); ++i) {
- ReportSummary summary = (ReportSummary) summaries.get(i);
+ ReportSummary summary = summaries.get(i);
int index = i + 1;
tempSummariesTable.setHTML(index, 0, "<a href=\"javascript:void(0)\">"
+ summary.getId() + "</a>");
@@ -445,13 +438,13 @@
*/
private void getReportDetails(String id) {
statusLabel.setText("Retrieving the report...");
- reportServer.getReport(id, new AsyncCallback() {
+ reportServer.getReport(id, new AsyncCallback<Report>() {
public void onFailure(Throwable caught) {
statusLabel.setText(caught.toString());
}
- public void onSuccess(Object result) {
- report = (Report) result;
+ public void onSuccess(Report result) {
+ report = result;
statusLabel.setText("Finished fetching report details.");
displayReport();
}
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Result.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Result.java
similarity index 75%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Result.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Result.java
index 7ee6efa..d6add52 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Result.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Result.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
import com.google.gwt.user.client.rpc.IsSerializable;
@@ -26,12 +26,11 @@
private String agent;
+ private String exception;
+
private String host;
- /**
- * @gwt.typeArgs <com.google.gwt.junit.viewer.client.Trial>
- */
- private List trials;
+ private List<Trial> trials;
public Result() {
}
@@ -40,11 +39,15 @@
return agent;
}
+ public String getException() {
+ return exception;
+ }
+
public String getHost() {
return host;
}
- public List getTrials() {
+ public List<Trial> getTrials() {
return trials;
}
@@ -52,11 +55,15 @@
this.agent = agent;
}
+ public void setException(String exception) {
+ this.exception = exception;
+ }
+
public void setHost(String host) {
this.host = host;
}
- public void setTrials(List trials) {
+ public void setTrials(List<Trial> trials) {
this.trials = trials;
}
}
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Trial.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Trial.java
similarity index 70%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Trial.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Trial.java
index 5bd3a54..604dfc1 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/client/Trial.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/client/Trial.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.client;
+package com.google.gwt.benchmarks.viewer.client;
import com.google.gwt.user.client.rpc.IsSerializable;
@@ -25,22 +25,9 @@
*/
public class Trial implements IsSerializable {
- String exception;
+ private double runTimeMillis;
- double runTimeMillis;
-
- /**
- * @gwt.typeArgs <java.lang.String,java.lang.String>
- */
- Map/* <String,String> */variables;
-
- public Trial() {
- this.variables = new HashMap();
- }
-
- public String getException() {
- return exception;
- }
+ private Map<String, String> variables = new HashMap<String, String>();
public double getRunTimeMillis() {
return runTimeMillis;
@@ -50,14 +37,10 @@
* Returns the names and values of the variables used in the test. If there
* were no variables, the map is empty.
*/
- public Map getVariables() {
+ public Map<String, String> getVariables() {
return variables;
}
- public void setException(String exception) {
- this.exception = exception;
- }
-
public void setRunTimeMillis(double runTimeMillis) {
this.runTimeMillis = runTimeMillis;
}
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/public/ReportViewer.css b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/public/ReportViewer.css
similarity index 100%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/public/ReportViewer.css
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/public/ReportViewer.css
diff --git a/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/public/ReportViewer.html b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/public/ReportViewer.html
new file mode 100644
index 0000000..d58fc13
--- /dev/null
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/public/ReportViewer.html
@@ -0,0 +1,8 @@
+<html>
+ <head>
+ <title>ReportViewer</title>
+ </head>
+ <body bgcolor="white">
+ <script language="javascript" src="com.google.gwt.benchmarks.viewer.ReportViewer.nocache.js"></script>
+ </body>
+</html>
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/public/gradient.gif b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/public/gradient.gif
similarity index 100%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/public/gradient.gif
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/public/gradient.gif
Binary files differ
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/BenchmarkXml.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/BenchmarkXml.java
similarity index 75%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/BenchmarkXml.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/BenchmarkXml.java
index b47ae72..933788a 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/BenchmarkXml.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/BenchmarkXml.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,9 +13,10 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.server;
+package com.google.gwt.benchmarks.viewer.server;
-import com.google.gwt.junit.viewer.client.Benchmark;
+import com.google.gwt.benchmarks.viewer.client.Benchmark;
+import com.google.gwt.benchmarks.viewer.client.Result;
import org.w3c.dom.Element;
@@ -34,10 +35,10 @@
benchmark.setName(element.getAttribute("name"));
benchmark.setDescription(element.getAttribute("description"));
- List children = ReportXml.getElementChildren(element, "result");
- benchmark.setResults(new ArrayList/* <Result> */(children.size()));
+ List<Element> children = ReportXml.getElementChildren(element, "result");
+ benchmark.setResults(new ArrayList<Result>(children.size()));
for (int i = 0; i < children.size(); ++i) {
- benchmark.getResults().add(ResultXml.fromXml((Element) children.get(i)));
+ benchmark.getResults().add(ResultXml.fromXml(children.get(i)));
}
Element code = ReportXml.getElementChild(element, "source_code");
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/CategoryXml.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/CategoryXml.java
similarity index 70%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/CategoryXml.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/CategoryXml.java
index 2c10a64..1ca5ffa 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/CategoryXml.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/CategoryXml.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,9 +13,10 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.server;
+package com.google.gwt.benchmarks.viewer.server;
-import com.google.gwt.junit.viewer.client.Category;
+import com.google.gwt.benchmarks.viewer.client.Benchmark;
+import com.google.gwt.benchmarks.viewer.client.Category;
import org.w3c.dom.Element;
@@ -32,12 +33,10 @@
category.setName(element.getAttribute("name"));
category.setDescription(element.getAttribute("description"));
- List/* <Element> */children = ReportXml.getElementChildren(element,
- "benchmark");
- category.setBenchmarks(new ArrayList/* <Benchmark> */(children.size()));
+ List<Element> children = ReportXml.getElementChildren(element, "benchmark");
+ category.setBenchmarks(new ArrayList<Benchmark>(children.size()));
for (int i = 0; i < children.size(); ++i) {
- category.getBenchmarks().add(
- BenchmarkXml.fromXml((Element) children.get(i)));
+ category.getBenchmarks().add(BenchmarkXml.fromXml(children.get(i)));
}
return category;
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportDatabase.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportDatabase.java
similarity index 83%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportDatabase.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportDatabase.java
index 63fde7e..8d3160b 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportDatabase.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportDatabase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.server;
+package com.google.gwt.benchmarks.viewer.server;
-import com.google.gwt.junit.client.Benchmark;
-import com.google.gwt.junit.viewer.client.Report;
-import com.google.gwt.junit.viewer.client.ReportSummary;
+import com.google.gwt.benchmarks.client.Benchmark;
+import com.google.gwt.benchmarks.viewer.client.Report;
+import com.google.gwt.benchmarks.viewer.client.ReportSummary;
import org.w3c.dom.Document;
@@ -59,9 +59,9 @@
}
private static class ReportEntry {
- private ReportSummary summary;
- private Report report;
private long lastModified;
+ private Report report;
+ private ReportSummary summary;
public ReportEntry(Report report, ReportSummary summary, long lastModified) {
this.report = report;
@@ -80,13 +80,13 @@
}
}
+ private static ReportDatabase database = new ReportDatabase();
+
/**
* The amount of time to go between report updates.
*/
private static final int UPDATE_DURATION_MILLIS = 30000;
- private static ReportDatabase database = new ReportDatabase();
-
public static ReportDatabase getInstance() {
return database;
}
@@ -96,16 +96,26 @@
}
/**
- * A list of all reports by id.
- */
- private Map/* <String,ReportEntry> */reports = new HashMap/* <String,ReportEntry> */();
-
- /**
* The last time we updated our reports.
*/
private long lastUpdateMillis = -1L;
/**
+ * The path to read benchmark reports from.
+ */
+ private final String reportPath;
+
+ /**
+ * A list of all reports by id.
+ */
+ private Map<String, ReportEntry> reports = new HashMap<String, ReportEntry>();
+
+ /**
+ * Lock for reports.
+ */
+ private Object reportsLock = new Object();
+
+ /**
* Lock for updating from file system. (Guarantees a single update while not
* holding reportsLock open).
*/
@@ -116,16 +126,6 @@
*/
private boolean updating = false;
- /**
- * Lock for reports.
- */
- private Object reportsLock = new Object();
-
- /**
- * The path to read benchmark reports from.
- */
- private final String reportPath;
-
private ReportDatabase() throws BadPathException {
String path = System.getProperty(Benchmark.REPORT_PATH);
if (path == null || path.trim().equals("")) {
@@ -140,12 +140,12 @@
public Report getReport(String reportId) {
synchronized (reportsLock) {
- ReportEntry entry = (ReportEntry) reports.get(reportId);
+ ReportEntry entry = reports.get(reportId);
return entry == null ? null : entry.report;
}
}
- public List/* <ReportSummary> */getReportSummaries() {
+ public List<ReportSummary> getReportSummaries() {
/**
* There are probably ways to make this faster, but I've taken basic
@@ -171,10 +171,9 @@
}
synchronized (reportsLock) {
- List/* <ReportSummary> */summaries = new ArrayList/* <ReportSummary> */(
+ List<ReportSummary> summaries = new ArrayList<ReportSummary>(
reports.size());
- for (Iterator it = reports.values().iterator(); it.hasNext();) {
- ReportEntry entry = (ReportEntry) it.next();
+ for (ReportEntry entry : reports.values()) {
summaries.add(entry.summary);
}
return summaries;
@@ -191,8 +190,8 @@
}
});
- Map filesToUpdate = new HashMap();
- Map filesById = new HashMap();
+ Map<String, ReportEntry> filesToUpdate = new HashMap<String, ReportEntry>();
+ Map<String, ReportFile> filesById = new HashMap<String, ReportFile>();
for (int i = 0; i < files.length; ++i) {
File f = files[i];
filesById.put(getReportId(f), new ReportFile(f));
@@ -207,16 +206,15 @@
for (int i = 0; i < files.length; ++i) {
File file = files[i];
String reportId = getReportId(file);
- ReportEntry entry = (ReportEntry) reports.get(reportId);
+ ReportEntry entry = reports.get(reportId);
if (entry == null || entry.lastModified < file.lastModified()) {
filesToUpdate.put(reportId, null);
}
}
// Remove reports which no longer exist
- for (Iterator it = reports.keySet().iterator(); it.hasNext();) {
- String id = (String) it.next();
- if (filesById.get(id) == null) {
+ for (Iterator<String> it = reports.keySet().iterator(); it.hasNext();) {
+ if (filesById.get(it.next()) == null) {
it.remove();
}
}
@@ -228,9 +226,8 @@
factory.setIgnoringComments(true);
DocumentBuilder builder = factory.newDocumentBuilder();
- for (Iterator it = filesToUpdate.keySet().iterator(); it.hasNext();) {
- String id = (String) it.next();
- ReportFile reportFile = (ReportFile) filesById.get(id);
+ for (String id : filesToUpdate.keySet()) {
+ ReportFile reportFile = filesById.get(id);
String filePath = reportFile.file.getAbsolutePath();
Document doc = builder.parse(filePath);
Report report = ReportXml.fromXml(doc.getDocumentElement());
@@ -242,8 +239,7 @@
// Update the reports
synchronized (reportsLock) {
- for (Iterator it = filesToUpdate.keySet().iterator(); it.hasNext();) {
- String id = (String) it.next();
+ for (String id : filesToUpdate.keySet()) {
reports.put(id, filesToUpdate.get(id));
}
}
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportImageServer.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportImageServer.java
similarity index 74%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportImageServer.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportImageServer.java
index 0e90015..07ca35d 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportImageServer.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportImageServer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,48 +13,46 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.server;
+package com.google.gwt.benchmarks.viewer.server;
-import com.google.gwt.junit.viewer.client.Benchmark;
-import com.google.gwt.junit.viewer.client.BrowserInfo;
-import com.google.gwt.junit.viewer.client.Category;
-import com.google.gwt.junit.viewer.client.Report;
-import com.google.gwt.junit.viewer.client.Result;
-import com.google.gwt.junit.viewer.client.Trial;
+import com.google.gwt.benchmarks.viewer.client.Benchmark;
+import com.google.gwt.benchmarks.viewer.client.BrowserInfo;
+import com.google.gwt.benchmarks.viewer.client.Category;
+import com.google.gwt.benchmarks.viewer.client.Report;
+import com.google.gwt.benchmarks.viewer.client.Result;
+import com.google.gwt.benchmarks.viewer.client.Trial;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.ValueAxis;
-import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.encoders.EncoderUtil;
import org.jfree.chart.encoders.ImageFormat;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.DefaultDrawingSupplier;
+import org.jfree.chart.plot.DrawingSupplier;
+import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.plot.Plot;
-import org.jfree.chart.plot.DrawingSupplier;
-import org.jfree.chart.plot.DefaultDrawingSupplier;
-import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.data.xy.XYDataItem;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
-import java.awt.image.BufferedImage;
+import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
-import java.awt.BasicStroke;
-import java.awt.Shape;
import java.awt.Polygon;
-import java.awt.geom.Rectangle2D;
+import java.awt.Shape;
import java.awt.geom.Ellipse2D;
-import java.io.ByteArrayInputStream;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -93,30 +91,23 @@
private static final String charset = "UTF-8";
- private static void copy(InputStream in, OutputStream out) throws IOException {
- byte[] buf = new byte[512];
-
- while (true) {
- int bytesRead = in.read(buf);
- if (bytesRead == -1) {
- break;
- }
- out.write(buf, 0, bytesRead);
- }
- }
-
+ @Override
public void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
handleRequest(request, response);
} catch (Exception e) {
- logException("An error occured while trying to create the chart.", e,
- response);
+ if (e.getClass().getName().endsWith("ClientAbortException")) {
+ // No big deal, the client browser terminated a download.
+ } else {
+ logException("An error occured while trying to create the chart.", e,
+ response);
+ }
return;
}
}
private JFreeChart createChart(String testName, Result result, String title,
- List comparativeResults) {
+ List<Result> comparativeResults) {
// Find the maximum values across both axes for all of the results
// (this chart's own results, plus all comparative results).
@@ -127,20 +118,20 @@
double maxTime = 0;
- for (int i = 0; i < comparativeResults.size(); ++i) {
- Result r = (Result) comparativeResults.get(i);
- List resultTrials = r.getTrials();
-
- for (int j = 0; j < resultTrials.size(); ++j) {
- Trial t = (Trial) resultTrials.get(j);
+ for (Result r : comparativeResults) {
+ for (Trial t : r.getTrials()) {
maxTime = Math.max(maxTime, t.getRunTimeMillis());
}
}
// Determine the number of variables in this benchmark method
- List trials = result.getTrials();
- Trial firstTrial = (Trial) trials.get(0);
- int numVariables = firstTrial.getVariables().size();
+ List<Trial> trials = result.getTrials();
+ Trial firstTrial = new Trial();
+ int numVariables = 0;
+ if (trials.size() > 0) {
+ firstTrial = trials.get(0);
+ numVariables = firstTrial.getVariables().size();
+ }
// Display the trial data.
//
@@ -154,52 +145,47 @@
String domainVariable = null;
String seriesVariable = null;
- Map/* <String,Set<String>> */variableValues = null;
+ Map<String, Set<String>> variableValues = null;
if (numVariables == 1) {
- domainVariable = (String) firstTrial.getVariables().keySet().iterator().next();
+ domainVariable = firstTrial.getVariables().keySet().iterator().next();
} else {
// TODO(tobyr): Do something smarter, like allow the user to specify which
// variables are domain and series, along with the variables which are
// held constant.
- variableValues = new HashMap();
+ variableValues = new HashMap<String, Set<String>>();
for (int i = 0; i < trials.size(); ++i) {
- Trial trial = (Trial) trials.get(i);
- Map variables = trial.getVariables();
+ Trial trial = trials.get(i);
+ Map<String, String> variables = trial.getVariables();
- for (Iterator it = variables.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- String variable = (String) entry.getKey();
- String value = (String) entry.getValue();
- Set set = (Set) variableValues.get(variable);
+ for (Map.Entry<String, String> entry : variables.entrySet()) {
+ String variable = entry.getKey();
+ Set<String> set = variableValues.get(variable);
if (set == null) {
- set = new TreeSet();
+ set = new TreeSet<String>();
variableValues.put(variable, set);
}
- set.add(value);
+ set.add(entry.getValue());
}
}
- TreeMap numValuesMap = new TreeMap();
+ TreeMap<Integer, List<String>> numValuesMap = new TreeMap<Integer, List<String>>();
- for (Iterator it = variableValues.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- String variable = (String) entry.getKey();
- Set values = (Set) entry.getValue();
- Integer numValues = new Integer(values.size());
- List variables = (List) numValuesMap.get(numValues);
+ for (Map.Entry<String, Set<String>> entry : variableValues.entrySet()) {
+ Integer numValues = new Integer(entry.getValue().size());
+ List<String> variables = numValuesMap.get(numValues);
if (variables == null) {
- variables = new ArrayList();
+ variables = new ArrayList<String>();
numValuesMap.put(numValues, variables);
}
- variables.add(variable);
+ variables.add(entry.getKey());
}
if (numValuesMap.values().size() > 0) {
- domainVariable = (String) ((List) numValuesMap.get(numValuesMap.lastKey())).get(0);
- seriesVariable = (String) ((List) numValuesMap.get(numValuesMap.firstKey())).get(0);
+ domainVariable = numValuesMap.get(numValuesMap.lastKey()).get(0);
+ seriesVariable = numValuesMap.get(numValuesMap.firstKey()).get(0);
}
}
@@ -208,10 +194,8 @@
if (numVariables == 0) {
// Show a bar graph, with a single centered simple bar
// 0 variables means there is only 1 trial
- Trial trial = (Trial) trials.iterator().next();
-
DefaultCategoryDataset data = new DefaultCategoryDataset();
- data.addValue(trial.getRunTimeMillis(), "result", "result");
+ data.addValue(firstTrial.getRunTimeMillis(), "result", "result");
JFreeChart chart = ChartFactory.createBarChart(title, testName,
valueTitle, data, PlotOrientation.VERTICAL, false, false, false);
@@ -229,13 +213,9 @@
XYSeries series = new XYSeries(domainVariable);
- for (Iterator it = trials.iterator(); it.hasNext();) {
- Trial trial = (Trial) it.next();
- if (trial.getException() != null) {
- continue;
- }
+ for (Trial trial : trials) {
double time = trial.getRunTimeMillis();
- String domainValue = (String) trial.getVariables().get(domainVariable);
+ String domainValue = trial.getVariables().get(domainVariable);
series.add(Double.parseDouble(domainValue), time);
}
@@ -252,22 +232,16 @@
// Show a line graph with two series
XYSeriesCollection data = new XYSeriesCollection();
- Set seriesValues = (Set) variableValues.get(seriesVariable);
+ Set<String> seriesValues = variableValues.get(seriesVariable);
- for (Iterator it = seriesValues.iterator(); it.hasNext();) {
- String seriesValue = (String) it.next();
+ for (String seriesValue : seriesValues) {
XYSeries series = new XYSeries(seriesValue);
- for (Iterator trialsIt = trials.iterator(); trialsIt.hasNext();) {
- Trial trial = (Trial) trialsIt.next();
- if (trial.getException() != null) {
- continue;
- }
- Map variables = trial.getVariables();
+ for (Trial trial : trials) {
+ Map<String, String> variables = trial.getVariables();
if (variables.get(seriesVariable).equals(seriesValue)) {
double time = trial.getRunTimeMillis();
- String domainValue = (String) trial.getVariables().get(
- domainVariable);
+ String domainValue = trial.getVariables().get(domainVariable);
series.add(Double.parseDouble(domainValue), time);
}
}
@@ -329,9 +303,8 @@
*/
}
- private Benchmark getBenchmarkByName(List benchmarks, String name) {
- for (Iterator it = benchmarks.iterator(); it.hasNext();) {
- Benchmark benchmark = (Benchmark) it.next();
+ private Benchmark getBenchmarkByName(List<Benchmark> benchmarks, String name) {
+ for (Benchmark benchmark : benchmarks) {
if (benchmark.getName().equals(name)) {
return benchmark;
}
@@ -339,9 +312,9 @@
return null;
}
- private Category getCategoryByName(List categories, String categoryName) {
- for (Iterator catIt = categories.iterator(); catIt.hasNext();) {
- Category category = (Category) catIt.next();
+ private Category getCategoryByName(List<Category> categories,
+ String categoryName) {
+ for (Category category : categories) {
if (category.getName().equals(categoryName)) {
return category;
}
@@ -377,27 +350,26 @@
circle, square, triangle, diamond, ellipse});
}
- private double getMaxValue(List results, String variable) {
+ private double getMaxValue(List<Result> results, String variable) {
double value = 0.0;
for (int i = 0; i < results.size(); ++i) {
- Result r = (Result) results.get(i);
- List resultTrials = r.getTrials();
+ Result r = results.get(i);
+ List<Trial> resultTrials = r.getTrials();
for (int j = 0; j < resultTrials.size(); ++j) {
- Trial t = (Trial) resultTrials.get(j);
- Map variables = t.getVariables();
- value = Math.max(value,
- Double.parseDouble((String) variables.get(variable)));
+ Trial t = resultTrials.get(j);
+ Map<String, String> variables = t.getVariables();
+ value = Math.max(value, Double.parseDouble(variables.get(variable)));
}
}
return value;
}
- private Result getResultsByAgent(List results, String agent) {
- for (Iterator it = results.iterator(); it.hasNext();) {
- Result result = (Result) it.next();
+ private Result getResultsByAgent(List<Result> results, String agent) {
+ for (Object element : results) {
+ Result result = (Result) element;
if (result.getAgent().equals(agent)) {
return result;
}
@@ -420,11 +392,11 @@
ReportDatabase db = ReportDatabase.getInstance();
Report report = db.getReport(reportName);
- List categories = report.getCategories();
+ List<Category> categories = report.getCategories();
Category category = getCategoryByName(categories, categoryName);
- List benchmarks = category.getBenchmarks();
+ List<Benchmark> benchmarks = category.getBenchmarks();
Benchmark benchmark = getBenchmarkByName(benchmarks, testName);
- List results = benchmark.getResults();
+ List<Result> results = benchmark.getResults();
Result result = getResultsByAgent(results, agent);
String title = BrowserInfo.getBrowser(agent);
@@ -462,10 +434,14 @@
BufferedImage img = chart.createBufferedImage(graphWidth, 240);
byte[] image = EncoderUtil.encode(img, ImageFormat.PNG);
+ // The images have unique URLs; might as well set them to never expire.
+ response.setHeader("Cache-Control", "max-age=0");
+ response.setHeader("Expires", "Fri, 2 Jan 1970 00:00:00 GMT");
response.setContentType("image/png");
+ response.setContentLength(image.length);
OutputStream output = response.getOutputStream();
- copy(new ByteArrayInputStream(image), output);
+ output.write(image);
}
private void logException(String msg, Exception e,
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportServerImpl.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportServerImpl.java
similarity index 75%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportServerImpl.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportServerImpl.java
index 1a0a8e8..a6bae6b 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportServerImpl.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportServerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,10 +13,11 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.server;
+package com.google.gwt.benchmarks.viewer.server;
-import com.google.gwt.junit.viewer.client.Report;
-import com.google.gwt.junit.viewer.client.ReportServer;
+import com.google.gwt.benchmarks.viewer.client.Report;
+import com.google.gwt.benchmarks.viewer.client.ReportServer;
+import com.google.gwt.benchmarks.viewer.client.ReportSummary;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.util.List;
@@ -31,10 +32,7 @@
return ReportDatabase.getInstance().getReport(reportId);
}
- /**
- * @gwt.typeArgs <com.google.gwt.junit.viewer.client.ReportSummary>
- */
- public List/* <ReportSummary> */getReportSummaries() {
+ public List<ReportSummary> getReportSummaries() {
return ReportDatabase.getInstance().getReportSummaries();
}
}
\ No newline at end of file
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportXml.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportXml.java
similarity index 80%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportXml.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportXml.java
index 8ce5ddd..bcccbd8 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ReportXml.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ReportXml.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,9 +13,10 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.server;
+package com.google.gwt.benchmarks.viewer.server;
-import com.google.gwt.junit.viewer.client.Report;
+import com.google.gwt.benchmarks.viewer.client.Category;
+import com.google.gwt.benchmarks.viewer.client.Report;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -54,10 +55,10 @@
report.setGwtVersion(element.getAttribute("gwt_version"));
- List/* <Element> */children = getElementChildren(element, "category");
- report.setCategories(new ArrayList/* <Category> */(children.size()));
+ List<Element> children = getElementChildren(element, "category");
+ report.setCategories(new ArrayList<Category>(children.size()));
for (int i = 0; i < children.size(); ++i) {
- report.getCategories().add(CategoryXml.fromXml((Element) children.get(i)));
+ report.getCategories().add(CategoryXml.fromXml(children.get(i)));
}
return report;
@@ -68,10 +69,10 @@
return children.getLength() == 0 ? null : (Element) children.item(0);
}
- static List/* <Element> */getElementChildren(Element e, String name) {
+ static List<Element> getElementChildren(Element e, String name) {
NodeList children = e.getElementsByTagName(name);
int numElements = children.getLength();
- List/* <Element> */elements = new ArrayList/* <Element> */(numElements);
+ List<Element> elements = new ArrayList<Element>(numElements);
for (int i = 0; i < children.getLength(); ++i) {
Node n = children.item(i);
elements.add((Element) n);
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ResultXml.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ResultXml.java
similarity index 66%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ResultXml.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ResultXml.java
index c15aaa2..4365cca 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/ResultXml.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/ResultXml.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,9 +13,10 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.server;
+package com.google.gwt.benchmarks.viewer.server;
-import com.google.gwt.junit.viewer.client.Result;
+import com.google.gwt.benchmarks.viewer.client.Result;
+import com.google.gwt.benchmarks.viewer.client.Trial;
import org.w3c.dom.Element;
@@ -24,21 +25,24 @@
/**
* Hydrates a benchmark Result from an XML Element.
- *
*/
public class ResultXml {
public static Result fromXml(Element element) {
Result result = new Result();
result.setAgent(element.getAttribute("agent"));
result.setHost(element.getAttribute("host"));
+ Element exception = ReportXml.getElementChild(element, "exception");
+ if (exception != null) {
+ result.setException(ReportXml.getText(exception));
+ }
- List/* <Element> */children = ReportXml.getElementChildren(element, "trial");
+ List<Element> children = ReportXml.getElementChildren(element, "trial");
- ArrayList trials = new ArrayList(children.size());
+ ArrayList<Trial> trials = new ArrayList<Trial>(children.size());
result.setTrials(trials);
for (int i = 0; i < children.size(); ++i) {
- trials.add(TrialXml.fromXml((Element) children.get(i)));
+ trials.add(TrialXml.fromXml(children.get(i)));
}
// TODO(tobyr) Put some type information in here for the variables
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/TrialXml.java b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/TrialXml.java
similarity index 67%
rename from tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/TrialXml.java
rename to tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/TrialXml.java
index 001c13f..d9ad3d0 100644
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/server/TrialXml.java
+++ b/tools/benchmark-viewer/src/com/google/gwt/benchmarks/viewer/server/TrialXml.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Google Inc.
+ * Copyright 2008 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
@@ -13,19 +13,17 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.google.gwt.junit.viewer.server;
+package com.google.gwt.benchmarks.viewer.server;
-import com.google.gwt.junit.viewer.client.Trial;
+import com.google.gwt.benchmarks.viewer.client.Trial;
import org.w3c.dom.Element;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Hydrates a benchmark Trial from an XML Element.
- *
*/
class TrialXml {
@@ -38,17 +36,11 @@
trial.setRunTimeMillis(Double.parseDouble(timing));
}
- Element exception = ReportXml.getElementChild(element, "exception");
- if (exception != null) {
- trial.setException(ReportXml.getText(exception));
- }
+ List<Element> elements = ReportXml.getElementChildren(element, "variable");
- List elements = ReportXml.getElementChildren(element, "variable");
+ Map<String, String> variables = trial.getVariables();
- Map variables = trial.getVariables();
-
- for (Iterator it = elements.iterator(); it.hasNext();) {
- Element e = (Element) it.next();
+ for (Element e : elements) {
String name = e.getAttribute("name");
String value = e.getAttribute("value");
variables.put(name, value);
diff --git a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/public/ReportViewer.html b/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/public/ReportViewer.html
deleted file mode 100644
index 0d43991..0000000
--- a/tools/benchmark-viewer/src/com/google/gwt/junit/viewer/public/ReportViewer.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<html>
- <head>
- <meta name='gwt:module' content='com.google.gwt.junit.viewer.ReportViewer'>
- <title>ReportViewer</title>
- </head>
- <body bgcolor="white">
- <script language="javascript" src="gwt.js"></script>
- </body>
-</html>