scale.common
Class Statistics

java.lang.Object
  extended by scale.common.Statistics

public class Statistics
extends java.lang.Object

This class registers statistics that are gathered by different classes.

$Id: Statistics.java,v 1.35 2007-08-27 18:37:51 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

A statistic is a scalar value kept by class. The name of the statistic is used to invoke a static method that returns the statistic for that class.

The status level is used to determine whether or not the "created" statistics should be collected. A level of 1 causes statistics to be collected. A level of 2 collects the "created" statistic as well.


Constructor Summary
Statistics()
           
 
Method Summary
static void cleanup()
          Clean up for profiling statistics.
static java.lang.String formatStat(java.lang.String className, java.lang.String stat, int value, java.lang.String forWhat)
          Format a statistic.
static java.lang.String formatStat(java.lang.String className, java.lang.String stat, java.lang.Object value, java.lang.String forWhat)
          Format a statistic.
static void print(java.io.PrintStream out, java.lang.String forWhat)
          Print out the values of the statistic specified for each class.
static void register(java.lang.String cn, java.lang.String stat)
          Register a class as keeping a statistic.
static void register(java.lang.String cn, java.lang.String[] stats)
          Register a class as keeping a list of statistics.
static void reportStatistics(int level, java.lang.String file)
          Print out the statistics if this status level is selected.
static void reportStatus(int msg)
          Print out the message is the status level is one.
static void reportStatus(int msg, int level)
          Print out the message is the status level is one.
static void reportStatus(int msg, java.lang.String text)
          Print out the message is the status level is one.
static void reportStatus(int msg, java.lang.String text1, int level)
          Print out the message if this status level is selected.
static void reportStatus(int msg, java.lang.String text1, java.lang.String text2, int level)
          Print out the message if this status level is selected.
static void setStatusLevel(int level, java.lang.String tag)
          Set the status level.
static void snapshot(java.lang.String snName)
          Take a snapshot of the statistics.
static boolean status(int level)
          Get the status level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Statistics

public Statistics()
Method Detail

setStatusLevel

public static void setStatusLevel(int level,
                                  java.lang.String tag)
Set the status level. The status level control the amount of status information that is printed.

Parameters:
level - a positive integer control the status level
tag - to specify for whom the statistic was generated

reportStatistics

public static void reportStatistics(int level,
                                    java.lang.String file)
Print out the statistics if this status level is selected.

Parameters:
level - the status level for this status

reportStatus

public static void reportStatus(int msg,
                                java.lang.String text1,
                                java.lang.String text2,
                                int level)
Print out the message if this status level is selected.

Parameters:
msg - is the status message
text1 - is additional information
text2 - is additional information
level - is the status level for this status
See Also:
Msg

reportStatus

public static void reportStatus(int msg,
                                java.lang.String text1,
                                int level)
Print out the message if this status level is selected.

Parameters:
msg - is the status message
text1 - is additional information
level - is the status level for this status
See Also:
Msg

reportStatus

public static void reportStatus(int msg)
Print out the message is the status level is one.

Parameters:
msg - is the status message
See Also:
Msg

reportStatus

public static void reportStatus(int msg,
                                int level)
Print out the message is the status level is one.

Parameters:
msg - is the status message
level - is the status level for this status
See Also:
Msg

reportStatus

public static void reportStatus(int msg,
                                java.lang.String text)
Print out the message is the status level is one.

Parameters:
msg - is the status message
text - is additional information
See Also:
Msg

status

public static boolean status(int level)
Get the status level. The status level control the amount of status information that is printed.

Parameters:
level - the status level
Returns:
true if at level level or greater

register

public static void register(java.lang.String cn,
                            java.lang.String[] stats)
Register a class as keeping a list of statistics.

Parameters:
stats - is a list of the names of the statistics
cn - is the class name.

register

public static void register(java.lang.String cn,
                            java.lang.String stat)
Register a class as keeping a statistic.

Parameters:
stat - is the name of the statistic
cn - is the class name.

snapshot

public static void snapshot(java.lang.String snName)
Take a snapshot of the statistics.

Parameters:
snName - a name to associate with this snapshot

formatStat

public static java.lang.String formatStat(java.lang.String className,
                                          java.lang.String stat,
                                          java.lang.Object value,
                                          java.lang.String forWhat)
Format a statistic. A statistic consists of four parts:
  1. the name of the class reporting the statistic,
  2. the name of the statistic,
  3. the value of the statistic, and
  4. a tag to be pre-pended.

Parameters:
className - is the name of the class reporting the statistic
stat - is the name of the statistic
value - is the value of the statistic
forWhat - is the tag
Returns:
the formatted string

formatStat

public static java.lang.String formatStat(java.lang.String className,
                                          java.lang.String stat,
                                          int value,
                                          java.lang.String forWhat)
Format a statistic. A statistic consists of four parts:
  1. the name of the class reporting the statistic,
  2. the name of the statistic,
  3. the value of the statistic, and
  4. a tag to be pre-pended.

Parameters:
className - is the name of the class reporting the statistic
stat - is the name of the statistic
value - is the value of the statistic
forWhat - is the tag
Returns:
the formatted string

print

public static void print(java.io.PrintStream out,
                         java.lang.String forWhat)
Print out the values of the statistic specified for each class.

Parameters:
out - is the PrintStream for the output
forWhat - is a string that is prepended to the statistics printed

cleanup

public static void cleanup()
Clean up for profiling statistics.