FileDocCategorySizeDatePackage
CodeStatistics.javaAPI DocAndroid 5.1 API5587Thu Mar 12 22:18:30 GMT 2015com.android.dx.dex.cf

CodeStatistics

public final class CodeStatistics extends Object
Static methods and variables for collecting statistics on generated code.

Fields Summary
private static final boolean
DEBUG
set to {@code true} to enable development-time debugging code
public static int
runningDeltaRegisters
running sum of the number of registers added/removed in SSA form by the optimizer
public static int
runningDeltaInsns
running sum of the number of insns added/removed in SSA form by the optimizer
public static int
runningTotalInsns
running sum of the total number of Rop insns processed
public static int
dexRunningDeltaRegisters
running sum of the number of dex-form registers added/removed in SSA form by the optimizer. Only valid if args.statistics is true.
public static int
dexRunningDeltaInsns
running sum of the number of dex-form insns (actually code units) added/removed in SSA form by the optimizer. Only valid if args.statistics is true.
public static int
dexRunningTotalInsns
running sum of the total number of dex insns (actually code units) processed
public static int
runningOriginalBytes
running sum of original class bytecode bytes
Constructors Summary
private CodeStatistics()
This class is uninstantiable.


             
      
        // This space intentionally left blank.
    
Methods Summary
public static voiddumpStatistics(java.io.PrintStream out)
Prints out the collected statistics.

param
out {@code non-null;} where to output to

        out.printf("Optimizer Delta Rop Insns: %d total: %d "
                + "(%.2f%%) Delta Registers: %d\n",
                runningDeltaInsns,
                runningTotalInsns,
                (100.0 * (((float) runningDeltaInsns)
                        / (runningTotalInsns + Math.abs(runningDeltaInsns)))),
                runningDeltaRegisters);

        out.printf("Optimizer Delta Dex Insns: Insns: %d total: %d "
                + "(%.2f%%) Delta Registers: %d\n",
                dexRunningDeltaInsns,
                dexRunningTotalInsns,
                (100.0 * (((float) dexRunningDeltaInsns)
                        / (dexRunningTotalInsns
                                + Math.abs(dexRunningDeltaInsns)))),
                dexRunningDeltaRegisters);

        out.printf("Original bytecode byte count: %d\n",
                runningOriginalBytes);
    
public static voidupdateDexStatistics(com.android.dx.dex.code.DalvCode nonOptCode, com.android.dx.dex.code.DalvCode code)
Updates the dex statistics.

param
nonOptCode non-optimized code block
param
code optimized code block

        if (DEBUG) {
            System.err.println("dex insns (old/new) "
                    + nonOptCode.getInsns().codeSize()
                    + "/" + code.getInsns().codeSize()
                    + " regs (o/n) "
                    + nonOptCode.getInsns().getRegistersSize()
                    + "/" + code.getInsns().getRegistersSize()
            );
        }

        dexRunningDeltaInsns
            += (code.getInsns().codeSize()
                - nonOptCode.getInsns().codeSize());

        dexRunningDeltaRegisters
            += (code.getInsns().getRegistersSize()
                - nonOptCode.getInsns().getRegistersSize());

        dexRunningTotalInsns += code.getInsns().codeSize();
    
public static voidupdateOriginalByteCount(int count)
Updates the number of original bytecode bytes processed.

param
count {@code >= 0;} the number of bytes to add

        runningOriginalBytes += count;
    
public static voidupdateRopStatistics(com.android.dx.rop.code.RopMethod nonOptRmeth, com.android.dx.rop.code.RopMethod rmeth)
Updates the ROP statistics.

param
nonOptRmeth non-optimized method
param
rmeth optimized method

        int oldCountInsns
                = nonOptRmeth.getBlocks().getEffectiveInstructionCount();
        int oldCountRegs = nonOptRmeth.getBlocks().getRegCount();

        if (DEBUG) {
            System.err.println("insns (old/new): "
                    + oldCountInsns + "/"
                    + rmeth.getBlocks().getEffectiveInstructionCount()
                    + " regs (o/n):" + oldCountRegs
                    + "/"  +  rmeth.getBlocks().getRegCount());
        }

        int newCountInsns
                = rmeth.getBlocks().getEffectiveInstructionCount();

        runningDeltaInsns
            += (newCountInsns - oldCountInsns);

        runningDeltaRegisters
            += (rmeth.getBlocks().getRegCount() - oldCountRegs);

        runningTotalInsns += newCountInsns;