Options options = new Options();
options.addOption("p", "product", true, "Class name of the product to use for benchmark");
options.addOption("n", true, "Number of repetitions");
Harness harness = new Harness();
harness.addMetric(new DeserializationSpeedMetric(0, false) {
public String toString() {
return "Initial run deserialization";
}
});
Parser parser = new PosixParser();
try {
CommandLine commandLine = parser.parse(options, args);
String name = null;
if (commandLine.hasOption('p')) {
name = commandLine.getOptionValue('p');
}
if (name == null || name.equals("DOM")) {
harness.addProduct(new XStreamDom());
}
if (name == null || name.equals("JDOM")) {
harness.addProduct(new XStreamJDom());
}
if (name == null || name.equals("DOM4J")) {
harness.addProduct(new XStreamDom4J());
}
if (name == null || name.equals("XOM")) {
harness.addProduct(new XStreamXom());
}
if (name == null || name.equals("BEAStAX")) {
harness.addProduct(new XStreamBEAStax());
}
if (name == null || name.equals("Woodstox")) {
harness.addProduct(new XStreamWoodstox());
}
if (JVM.is16() && (name == null || name.equals("SJSXP"))) {
harness.addProduct(new XStreamSjsxp());
}
if (name == null || name.equals("Xpp3")) {
harness.addProduct(new XStreamXpp3());
}
if (name == null || name.equals("kXML2")) {
harness.addProduct(new XStreamKXml2());
}
if (name == null || name.equals("Xpp3DOM")) {
harness.addProduct(new XStreamXpp3DOM());
}
if (name == null || name.equals("kXML2DOM")) {
harness.addProduct(new XStreamKXml2DOM());
}
if (commandLine.hasOption('n')) {
counter = Integer.parseInt(commandLine.getOptionValue('n'));
}
} catch (ParseException e) {
e.printStackTrace();
}
harness.addMetric(new DeserializationSpeedMetric(counter, false));
harness.addTarget(new BasicTarget());
harness.addTarget(new ExtendedTarget());
harness.addTarget(new ReflectionTarget());
harness.addTarget(new SerializableTarget());
harness.addTarget(new JavaBeanTarget());
if (false) {
harness.addTarget(new FieldReflection());
harness.addTarget(new HierarchyLevelReflection());
harness.addTarget(new InnerClassesReflection());
harness.addTarget(new StaticInnerClassesReflection());
}
harness.run(new TextReporter(new PrintWriter(System.out, true)));
System.out.println("Done.");
}