Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: editor/tools/plugins/com.google.dart.server_test/src/com/google/dart/server/timing/TestGroup.java

Issue 303233007: First cut at server timing tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed some bugs, added tests Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.server_test/src/com/google/dart/server/timing/TestGroup.java
diff --git a/editor/tools/plugins/com.google.dart.server_test/src/com/google/dart/server/timing/TestGroup.java b/editor/tools/plugins/com.google.dart.server_test/src/com/google/dart/server/timing/TestGroup.java
new file mode 100644
index 0000000000000000000000000000000000000000..7f1bee0f654e1a4f1651663c58ba754cc2a98a9c
--- /dev/null
+++ b/editor/tools/plugins/com.google.dart.server_test/src/com/google/dart/server/timing/TestGroup.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014, the Dart project authors.
+ *
+ * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
+ *
+ * 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.dart.server.timing;
+
+import java.io.PrintWriter;
+
+/**
+ * Instances of the class {@code TestGroup} represent objects that measure multiple ways of
+ * performing the same operation.
+ */
+public class TestGroup {
+ /**
+ * The name of the group.
+ */
+ private String name;
+
+ /**
+ * The tests that comprise the group.
+ */
+ TimingTest[] tests;
+
+ /**
+ * Initialize a newly created group
+ */
+ TestGroup(String name, TimingTest[] tests) {
+ this.name = name;
+ this.tests = tests;
+ }
+
+ /**
+ * Return the name of the group.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Run all of the tests in this group, writing timing information to the given writer.
+ *
+ * @param writer the writer to which results will be written.
+ */
+ public void runAll(PrintWriter writer) {
+ writer.println(name);
+ for (TimingTest test : tests) {
+ try {
+ TimingResult result = test.run();
+ int count = test.getTimingCount();
+ long time = result.getTotalTime();
+ writer.print(" ");
+ writer.print(test.getName());
+ writer.print(" : ");
+ writer.print(time);
+ writer.print(" (");
+ writer.print(result.getMinTime());
+ writer.print(", ");
+ writer.print(result.getAverageTime());
+ writer.print(", ");
+ writer.print(result.getMaxTime());
+ writer.print(", stdDev = ");
+ writer.print(Math.floor(result.getStandardDeviation() * 100.0) / 100.0);
+ writer.print(") for ");
+ writer.print(count);
+ writer.println(" iterations");
+ } catch (Exception exception) {
+ writer.print(" ");
+ writer.print(test.getName());
+ writer.print(" : ");
+ writer.println(exception.getMessage());
+ exception.printStackTrace(writer);
+ }
+ }
+ writer.println();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698