FileDocCategorySizeDatePackage
IndentingPrintWriterBenchmark.javaAPI DocAndroid 5.1 API4499Thu Mar 12 22:22:12 GMT 2015com.android.internal.util

IndentingPrintWriterBenchmark

public class IndentingPrintWriterBenchmark extends com.google.caliper.SimpleBenchmark

Fields Summary
private PrintWriter
mDirect
private IndentingPrintWriter
mIndenting
private Node
mSimple
private Node
mComplex
Constructors Summary
Methods Summary
protected voidsetUp()

        final FileOutputStream os = new FileOutputStream(new File("/dev/null"));
        mDirect = new PrintWriter(os);
        mIndenting = new IndentingPrintWriter(mDirect, "  ");

        final Node manyChildren = Node.build("ManyChildren", Node.build("1"), Node.build("2"),
                Node.build("3"), Node.build("4"), Node.build("5"), Node.build("6"), Node.build("7"),
                Node.build("8"), Node.build("9"), Node.build("10"));

        mSimple = Node.build("RED");
        mComplex = Node.build("PARENT", Node.build("RED"), Node.build("GREEN",
                Node.build("BLUE", manyChildren, manyChildren), manyChildren, manyChildren),
                manyChildren);
    
protected voidtearDown()

        mIndenting.close();
        mIndenting = null;
        mDirect = null;
    
public voidtimeComplexDirect(int reps)

        for (int i = 0; i < reps; i++) {
            mComplex.dumpDirect(mDirect, 0);
        }
    
public voidtimeComplexIndenting(int reps)

        for (int i = 0; i < reps; i++) {
            mComplex.dumpIndenting(mIndenting);
        }
    
public voidtimePairIndenting(int reps)

        final int value = 1024;
        for (int i = 0; i < reps; i++) {
            mIndenting.printPair("key", value);
        }
    
public voidtimePairRaw(int reps)

        final int value = 1024;
        for (int i = 0; i < reps; i++) {
            mDirect.print("key=");
            mDirect.print(value);
            mDirect.print(" ");
        }
    
public voidtimeSimpleDirect(int reps)

        for (int i = 0; i < reps; i++) {
            mSimple.dumpDirect(mDirect, 0);
        }
    
public voidtimeSimpleIndenting(int reps)

        for (int i = 0; i < reps; i++) {
            mSimple.dumpIndenting(mIndenting);
        }