Package com.thoughtworks.xstream.tools.benchmark

Examples of com.thoughtworks.xstream.tools.benchmark.Harness


       
        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.");
    }
View Full Code Here


            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
       
        Harness harness = new Harness();
        // harness.addMetric(new SerializationSpeedMetric(1) {
        // public String toString() {
        // return "Initial run serialization";
        // }
        // });
        // harness.addMetric(new DeserializationSpeedMetric(1, false) {
        // public String toString() {
        // return "Initial run deserialization";
        // }
        // });
        harness.addMetric(new SerializationSpeedMetric(counter));
        harness.addMetric(new DeserializationSpeedMetric(counter, false));
        if (product == null) {
            harness.addProduct(new NoCache());
            harness.addProduct(new Cache122());
            harness.addProduct(new RealClassCache());
            harness.addProduct(new SerializedClassCache());
            harness.addProduct(new AliasedAttributeCache());
            harness.addProduct(new DefaultImplementationCache());
            harness.addProduct(new NoCache());
        } else {
            harness.addProduct(product);
        }
        harness.addTarget(new BasicTarget());
        harness.addTarget(new ExtendedTarget());
        harness.addTarget(new ReflectionTarget());
        harness.addTarget(new SerializableTarget());
        harness.run(new TextReporter(new PrintWriter(System.out, true)));
        System.out.println("Done.");
    }
View Full Code Here

*
* @author Jörg Schaible
*/
public class StringsBenchmark {
    public static void main(String[] args) {
        Harness harness = new Harness();
        harness.addMetric(new DeserializationSpeedMetric(10, true));
        harness.addProduct(new StringNonCachingConverter());
        harness.addProduct(new StringInternConverter());
        harness.addProduct(new StringWithWeakHashMapConverter());
        harness.addProduct(new StringWithSynchronizedWeakHashMapConverter());
        harness.addTarget(new BigString());
        harness.addTarget(new StringArray(1024, 1024, 128));
        harness.addTarget(new StringArray(64 * 1024, 8, 32));
        harness.run(new TextReporter());
    }
View Full Code Here

                new HtmlReporter(new File(basename + ".html"), "XmlFriendlyReplacer Benchmark")};
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        Harness stats = new Harness();
        stats.addMetric(new SizeMetric());
        stats.addMetric(new CharacterCountMetric('$'));
        stats.addMetric(new CharacterCountMetric('_'));
        stats.addProduct(new NoReplacer());
        stats.addTarget(new FieldReflection());
        stats.addTarget(new Field_Reflection());
        stats.addTarget(new Field$Reflection());
        stats.run(new MultiReporter(reporters) {

            public void endBenchmark() {
                // do nothing
            }

        });

        Harness harness = new Harness();
        harness.addMetric(new SerializationSpeedMetric(100));
        harness.addMetric(new DeserializationSpeedMetric(100, false));
        harness.addProduct(new CombinedLookupReplacer(0));
        // harness.addProduct(new CombinedLookupReplacer(32));
        harness.addProduct(new CombinedLookupAppender(0));
        // harness.addProduct(new CombinedLookupAppender(32));
        harness.addProduct(new SeparateLookupReplacer(0));
        // harness.addProduct(new SeparateLookupReplacer(32));
        harness.addProduct(new IterativeReplacer(0));
        // harness.addProduct(new IterativeReplacer(32));
        harness.addProduct(new IterativeAppender(0));
        // harness.addProduct(new IterativeAppender(32));
        harness.addProduct(new IterativeAppenderWithShortcut());
        harness.addProduct(new CachingIterativeAppenderWithShortcut());
        harness.addTarget(new FieldReflection());
        harness.addTarget(new Field_Reflection());
        harness.addTarget(new Field$Reflection());
        harness.run(new MultiReporter(reporters) {

            public void startBenchmark() {
                // do nothing
            }
View Full Code Here

*
* @author Jörg Schaible
*/
public class ReflectionBenchmark {
    public static void main(String[] args) {
        Harness harness = new Harness();
        harness.addMetric(new SerializationSpeedMetric(10));
        harness.addMetric(new DeserializationSpeedMetric(10, true));
        harness.addProduct(new XStreamPlain());
        harness.addProduct(new XStreamClassAliases());
        harness.addProduct(new XStreamFieldAliases());
        harness.addProduct(new XStreamLocalAttributeAliases());
        harness.addTarget(new FieldReflection());
        harness.addTarget(new HierarchyLevelReflection());
        harness.addTarget(new InnerClassesReflection());
        harness.addTarget(new StaticInnerClassesReflection());
        harness.run(new TextReporter());
    }
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.tools.benchmark.Harness

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.