harpoon.Analysis.Counters
Class CounterFactory

java.lang.Object
  extended by harpoon.Analysis.Counters.CounterFactory

public final class CounterFactory
extends Object

CounterFactory is a state-less instrumentation package, with the goal of making it as easy as possible to add counters and timers to executable code. It comes in several parts: we have a set of routines to splice in counter/time calls into Quad forms, and we have a post-processing HCodeFactory available from the codeFactory() method that will create the appropriate epilog code to report the counter values at program's end.

Counters are disabled by default. All counters can be enabled by setting the property harpoon.counters.enabled.all to "true" and particular counters can be enabled by setting the property harpoon.counters.enabled.{counter-name} to "true". Particular counters can be disabled by setting the property harpoon.counters.disabled.{counter-name} to "true" and all counters can be disabled by setting the property harpoon.counters.disabled.all to "true".

Counters can also be grouped into classes by naming them with dot-separated strings. For example, counters named 'foo.bar' and 'foo.baz' are both enabled by setting harpoon.counters.enabled.foo to "true"; the counters' actual name on output will be "foo_bar" and "foo_baz".

Version:
$Id: CounterFactory.java,v 1.4 2002/04/10 02:58:58 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Method Summary
static HCodeFactory codeFactory(HCodeFactory parent, Linker linker, HMethod main)
          HCodeFactory that will add calls to the counter-printing epilog at the end of the given main method and before calls to Runtime.exit().
static boolean inCounters(Edge e)
           
static boolean isEnabled(String counter_name)
          Returns the enabled/disabled status of the given counter_name.
static Edge spliceIncrement(QuadFactory qf, Edge e, String counter_name)
          Increment the named counter by 1 on the given edge.
static Edge spliceIncrement(QuadFactory qf, Edge e, String counter_name, long value)
          Increment the named counter by value on the given edge.
static Edge spliceIncrement(QuadFactory qf, Edge e, String counter_name, Temp Tvalue, boolean isLong)
          Increment the named counter by the amount in the Temp Tvalue on the given edge.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isEnabled

public static boolean isEnabled(String counter_name)
Returns the enabled/disabled status of the given counter_name. This can be used so that counter-support code may be added only when the counter it supports is actually enabled.


inCounters

public static boolean inCounters(Edge e)

codeFactory

public static HCodeFactory codeFactory(HCodeFactory parent,
                                       Linker linker,
                                       HMethod main)
HCodeFactory that will add calls to the counter-printing epilog at the end of the given main method and before calls to Runtime.exit().


spliceIncrement

public static Edge spliceIncrement(QuadFactory qf,
                                   Edge e,
                                   String counter_name)
Increment the named counter by 1 on the given edge.


spliceIncrement

public static Edge spliceIncrement(QuadFactory qf,
                                   Edge e,
                                   String counter_name,
                                   long value)
Increment the named counter by value on the given edge.


spliceIncrement

public static Edge spliceIncrement(QuadFactory qf,
                                   Edge e,
                                   String counter_name,
                                   Temp Tvalue,
                                   boolean isLong)
Increment the named counter by the amount in the Temp Tvalue on the given edge. If isLong is true, then Tvalue should have type long; else it should have type int.