org.perf4j.helpers
Class GroupedTimingStatisticsCsvFormatter

java.lang.Object
  extended by org.perf4j.helpers.GroupedTimingStatisticsCsvFormatter
All Implemented Interfaces:
GroupedTimingStatisticsFormatter

public class GroupedTimingStatisticsCsvFormatter
extends Object
implements GroupedTimingStatisticsFormatter

This helper formatter class outputs GroupedTimingStatistics in a comma-separated value format. This class supports two main types of formats:

Author:
Alex Devine

Nested Class Summary
protected static interface GroupedTimingStatisticsCsvFormatter.GroupedTimingStatisticsValueRetriever
           
protected static interface GroupedTimingStatisticsCsvFormatter.TimingStatsValueRetriever
           
 
Field Summary
static String DEFAULT_FORMAT_STRING
          The default format string for a non-pivoted formatter.
 
Constructor Summary
GroupedTimingStatisticsCsvFormatter()
          Creates a non-pivoted CSV formatter using the default format string.
GroupedTimingStatisticsCsvFormatter(boolean pivot, String configString)
          Creates a CSV formatter which allows you to config which values are output.
 
Method Summary
 String format(GroupedTimingStatistics stats)
          Formats the specified GroupedTimingStatistics instance for CSV output.
protected  String formatDate(long timeInMillis)
          Formats the specified time in yyyy-MM-dd HH:mm:ss format.
protected  GroupedTimingStatisticsCsvFormatter.GroupedTimingStatisticsValueRetriever parsePivotedTimingStatsConfig(String configName)
          Helper method parses the specified single element from a config string to return the corresponding GroupedTimingStatisticsValueRetriever.
protected  GroupedTimingStatisticsCsvFormatter.TimingStatsValueRetriever parseTimingStatsConfig(String configName)
          Helper method parses the specified single element from a config string to return the corresponding TimingStatsValueRetriever.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FORMAT_STRING

public static final String DEFAULT_FORMAT_STRING
The default format string for a non-pivoted formatter.

See Also:
Constant Field Values
Constructor Detail

GroupedTimingStatisticsCsvFormatter

public GroupedTimingStatisticsCsvFormatter()
Creates a non-pivoted CSV formatter using the default format string.


GroupedTimingStatisticsCsvFormatter

public GroupedTimingStatisticsCsvFormatter(boolean pivot,
                                           String configString)
Creates a CSV formatter which allows you to config which values are output.

Parameters:
pivot - Whether the output is pivoted (one row for each GroupedTimingStatisitcs) or not (one row for each tagged TimingStatistics item contained in the GroupedTimingStatisitcs).
configString - The config string defines which values will be output, and should be a comma-separated list of the values. Possible values if pivot is false are tag, start, stop, mean, min, max, stddev, count and tps. If pivot is true the possible values are start, stop, and then one of the statistics prefixed with the tag name. For example, a possible configString could be "start,stop,codeBlock1Mean,codeBlock2Max".
Method Detail

format

public String format(GroupedTimingStatistics stats)
Formats the specified GroupedTimingStatistics instance for CSV output.

Specified by:
format in interface GroupedTimingStatisticsFormatter
Parameters:
stats - the GroupedTimingStatistics instance, may not be null
Returns:
The output formatted according to the configString passed in on this formatter's constructor (or the DEFAULT_FORMAT_STRING).

formatDate

protected String formatDate(long timeInMillis)
Formats the specified time in yyyy-MM-dd HH:mm:ss format. Subclasses may override to give a different output.

Parameters:
timeInMillis - The time in milliseconds.
Returns:
The formatted date/time String

parsePivotedTimingStatsConfig

protected GroupedTimingStatisticsCsvFormatter.GroupedTimingStatisticsValueRetriever parsePivotedTimingStatsConfig(String configName)
Helper method parses the specified single element from a config string to return the corresponding GroupedTimingStatisticsValueRetriever.

Parameters:
configName - The element from the config string
Returns:
The corresponding GroupedTimingStatisticsValueRetriever
Throws:
IllegalArgumentException - Thrown if configName is an unknown value designator

parseTimingStatsConfig

protected GroupedTimingStatisticsCsvFormatter.TimingStatsValueRetriever parseTimingStatsConfig(String configName)
Helper method parses the specified single element from a config string to return the corresponding TimingStatsValueRetriever.

Parameters:
configName - The element from the config string
Returns:
The corresponding TimingStatsValueRetriever
Throws:
IllegalArgumentException - Thrown if configName is an unknown value designator


Copyright © 2008-2011 perf4j.org. All Rights Reserved.