diff --git a/microbench/pom.xml b/microbench/pom.xml
index f5d2e805f9..fbc075873b 100644
--- a/microbench/pom.xml
+++ b/microbench/pom.xml
@@ -53,45 +53,6 @@
true
-
- maven-antrun-plugin
-
-
- upload-caliper-reports
- deploy
-
- run
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-No .caliperrc file found; not uploading the benchmark report.
-Please follow the instructions at:
-
- * http://code.google.com/p/caliper/wiki/OnlineResults
-
-to upload and browse the benchmark results.
-
-
-
-
-
-
-
-
diff --git a/microbench/src/test/java/com/google/caliper/StandardVm.java b/microbench/src/test/java/com/google/caliper/StandardVm.java
new file mode 100644
index 0000000000..35220b9ccf
--- /dev/null
+++ b/microbench/src/test/java/com/google/caliper/StandardVm.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2012 The Netty Project
+ *
+ * The Netty Project licenses this file to you 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.caliper;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+import java.util.Collections;
+import java.util.List;
+
+final class StandardVm extends Vm {
+
+ @Override public List getVmSpecificOptions(MeasurementType type, Arguments arguments) {
+ if (!arguments.getCaptureVmLog()) {
+ return ImmutableList.of();
+ }
+
+ List result = Lists.newArrayList(
+ "-server", "-dsa", "-da", "-ea:io.netty...",
+ "-Xms768m", "-Xmx768m", "-XX:MaxDirectMemorySize=768m",
+ "-XX:+AggressiveOpts", "-XX:+UseBiasedLocking", "-XX:+UseFastAccessorMethods",
+ "-XX:+UseStringCache", "-XX:+OptimizeStringConcat",
+ "-XX:+HeapDumpOnOutOfMemoryError");
+
+ if (type == MeasurementType.TIME) {
+ Collections.addAll(
+ result,
+ "-XX:+PrintCompilation");
+ } else {
+ Collections.addAll(
+ result,
+ "-verbose:gc",
+ "-Xbatch",
+ "-XX:+UseSerialGC",
+ "-XX:+TieredCompilation");
+ }
+
+ return result;
+ }
+
+ public static String defaultVmName() {
+ return "java";
+ }
+}
diff --git a/microbench/src/test/java/io/netty/microbench/util/DefaultBenchmark.java b/microbench/src/test/java/io/netty/microbench/util/DefaultBenchmark.java
index 2089cce42b..943ba123fa 100644
--- a/microbench/src/test/java/io/netty/microbench/util/DefaultBenchmark.java
+++ b/microbench/src/test/java/io/netty/microbench/util/DefaultBenchmark.java
@@ -16,6 +16,7 @@
package io.netty.microbench.util;
+import com.google.caliper.CaliperRc;
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
import org.junit.Test;
@@ -26,6 +27,8 @@ import static org.junit.Assert.*;
public abstract class DefaultBenchmark extends SimpleBenchmark {
+ private static boolean warned;
+
private final int trials;
private final int warmupMillis;
private final int runMillis;
@@ -72,27 +75,54 @@ public abstract class DefaultBenchmark extends SimpleBenchmark {
fail("not a directory: " + reportDir.getAbsolutePath());
}
- deleteOldReports(reportDir);
+ boolean deleted = deleteOldReports(reportDir);
+
+ if (!warned) {
+ CaliperRc caliperrc = CaliperRc.INSTANCE;
+ if (caliperrc.getApiKey() == null || caliperrc.getPostUrl() == null) {
+ warned = true;
+ System.out.println();
+ System.out.println(" Cannot read the configuration properties from .caliperrc.");
+ System.out.println(" Please follow the instructions at:");
+ System.out.println();
+ System.out.println(" * http://code.google.com/p/caliper/wiki/OnlineResults");
+ System.out.println();
+ System.out.println(" to upload and browse the benchmark results.");
+ }
+ }
+
+ if (deleted || warned) {
+ // Insert a pretty newline.
+ System.out.println();
+ }
new Runner().run(
"--trials", String.valueOf(trials),
"--warmupMillis", String.valueOf(warmupMillis),
"--runMillis", String.valueOf(runMillis),
- "--captureVmLog",
"--saveResults", reportDir.getAbsolutePath(),
+ "--captureVmLog",
getClass().getName());
}
- private void deleteOldReports(File reportDir) {
+ private boolean deleteOldReports(File reportDir) {
final String prefix = getClass().getName() + '.';
final String suffix = ".json";
+
+ boolean deleted = false;
for (File f: reportDir.listFiles()) {
String name = f.getName();
if (name.startsWith(prefix) && name.endsWith(suffix)) {
if (f.delete()) {
+ if (!deleted) {
+ deleted = true;
+ System.out.println();
+ }
System.out.println(" Deleted old report: " + name.substring(prefix.length(), name.length() - suffix.length()));
}
}
}
+
+ return deleted;
}
}