harpoon.Instrumentation.AllocationStatistics
Class AllocationStatistics

java.lang.Object
  extended by harpoon.Instrumentation.AllocationStatistics.AllocationStatistics

public class AllocationStatistics
extends Object

AllocationStatistics reads the output produced by the allocation instrumentation and offers support for gathering and displaying statistics about the number of times each allocation site from an instrumented program was executed.

Version:
$Id: AllocationStatistics.java,v 1.7 2004/02/08 03:21:32 cananian Exp $
Author:
Alexandru Salcianu <salcianu@MIT.edu>
See Also:
InstrumentAllocs

Constructor Summary
AllocationStatistics(AllocationNumberingInterf ani, String instrumentationResultsFileName)
          Create an AllocationStatistics object.
AllocationStatistics(Linker linker, String allocNumberingFileName, String instrumentationResultsFileName)
          Create a AllocationStatistics.
 
Method Summary
 int allocID(Quad alloc)
          Returns the unique ID for alloc.
static Collection getAllocs(Set methods, HCodeFactory hcf)
          Return a collection of all the allocation sites (quads) from the methods from the set methods.
 long getCount(Quad alloc)
          Returns the number of times the allocation alloc was executed.
 long getMemAmount(Quad alloc)
          Returns the total amount of memory allocated at the allocation alloc.
static Map parseInstrumentationResults(String instrumentationResultsFileName)
          Parse the text file produced by an instrumented program.
 void printStatistics(Collection allocs)
           
 void printStatistics(Collection allocs, QuadVisitor visitor)
          Prints statitistics about the allocation sites from the collection allocs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AllocationStatistics

public AllocationStatistics(AllocationNumberingInterf ani,
                            String instrumentationResultsFileName)
Create an AllocationStatistics object.

Parameters:
ani - AllocationNumberingInterf object that provides the mapping between allocation sites and globally unique integer IDs.
instrumentationResultFileName - name of the file that holds the result of the instrumentation: for each unique ID, the number of times the associated allocation site was executed and the total amount of memory allocated there.

AllocationStatistics

public AllocationStatistics(Linker linker,
                            String allocNumberingFileName,
                            String instrumentationResultsFileName)
Create a AllocationStatistics.

Parameters:
linker - Linker used to load the classes.
allocNumberingFileName - name of the file that stores the textualized form of the AllocationNumberingStub (that associates to each allocation site a unique integer ID).
instrumentationResultFileName - name of the file that holds the result of the instrumentation: for each unique ID, the number of times the associated allocation site was executed.
Method Detail

getCount

public long getCount(Quad alloc)
Returns the number of times the allocation alloc was executed.

Parameters:
alloc - allocation site
Returns:
number of times alloc was executed

getMemAmount

public long getMemAmount(Quad alloc)
Returns the total amount of memory allocated at the allocation alloc.

Parameters:
alloc - allocation site
Returns:
total amount of memory allocated at alloc

allocID

public int allocID(Quad alloc)
Returns the unique ID for alloc.


printStatistics

public void printStatistics(Collection allocs,
                            QuadVisitor visitor)
Prints statitistics about the allocation sites from the collection allocs. If visitor is non-null, it is called on each allocation site (this way, one can customize the displayed statistics). The allocation sites are listed/visited in the decreasing order of the number of objects allocated there. Sites that allocate too few objects (less than 1% of the total objects) are not considered.


printStatistics

public void printStatistics(Collection allocs)

parseInstrumentationResults

public static Map parseInstrumentationResults(String instrumentationResultsFileName)
                                       throws IOException
Parse the text file produced by an instrumented program.

Parameters:
instrumentationResultsFileName - name of the file holding the instrumentation results
Returns:
map that attaches to each unique ID the data collected by the instrumentation for the corresponding allocation site.
Throws:
IOException

getAllocs

public static Collection getAllocs(Set methods,
                                   HCodeFactory hcf)
Return a collection of all the allocation sites (quads) from the methods from the set methods.

Parameters:
methods - methods where we look for allocation sites
hcf - code factory that provides the code of the methods
Returns:
collection of all allocation sites (quads) from methods