org.geotoolkit.util.logging
Class PerformanceLevel

Object
  extended by Level
      extended by PerformanceLevel
All Implemented Interfaces:
Serializable

public final class PerformanceLevel
extends Level

Logging levels for measurements of execution time. Different logging levels - SLOW, SLOWER and SLOWEST - are provided in order to log only the events taking more than some time duration. For example the console could log only the slowest events, while a file could log all events considered slow.

Every levels defined in this class have a value between the Level.FINE and Level.CONFIG values. Consequently performance logging are disabled by default, and enabling them imply enabling configuration logging too. This is done that way because the configuration typically have a significant impact on performance.


Enabling performance logging
Performance logging can be enabled in various ways. Among others:

Since:
3.16
Version:
3.16
Author:
Martin Desruisseaux (Geomatys)
See Also:
Serialized Form
Module:
utility/geotk-utility (download)    View source code for this class

Field Summary
static PerformanceLevel PERFORMANCE
          The level for logging all time measurements, regardless of their duration.
static PerformanceLevel SLOW
          The level for logging relatively slow events.
static PerformanceLevel SLOWER
          The level for logging only events slower than the ones logged at the SLOW level.
static PerformanceLevel SLOWEST
          The level for logging only slowest events.
 
Fields inherited from class Level
ALL, CONFIG, FINE, FINER, FINEST, INFO, OFF, SEVERE, WARNING
 
Method Summary
static PerformanceLevel forDuration(long duration, TimeUnit unit)
          Returns the level to use for logging an event of the given duration.
 long getMinDuration(TimeUnit unit)
          Returns the minimal duration for logging an event at this level.
 void setMinDuration(long duration, TimeUnit unit)
          Sets the minimal duration for logging an event at this level.
 
Methods inherited from class Level
equals, getLocalizedName, getName, getResourceBundleName, hashCode, intValue, parse, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PERFORMANCE

public static final PerformanceLevel PERFORMANCE
The level for logging all time measurements, regardless of their duration. The value of this level is 600.


SLOW

public static final PerformanceLevel SLOW
The level for logging relatively slow events. By default, only events having an execution time equals or greater than 0.1 second are logged at this level. However this threshold can be changed by a call to SLOW.setMinDuration(long, TimeUnit).


SLOWER

public static final PerformanceLevel SLOWER
The level for logging only events slower than the ones logged at the SLOW level. By default, only events having an execution time equals or greater than 1 second are logged at this level. However this threshold can be changed by a call to SLOWER.setMinDuration(long, TimeUnit).


SLOWEST

public static final PerformanceLevel SLOWEST
The level for logging only slowest events. By default, only events having an execution time equals or greater than 5 seconds are logged at this level. However this threshold can be changed by a call to SLOWEST.setMinDuration(long, TimeUnit).

Method Detail

forDuration

public static PerformanceLevel forDuration(long duration,
                                           TimeUnit unit)
Returns the level to use for logging an event of the given duration.

Parameters:
duration - The event duration.
unit - The unit of the given duration value.
Returns:
The level to use for logging an event of the given duration.

getMinDuration

public long getMinDuration(TimeUnit unit)
Returns the minimal duration for logging an event at this level.

Parameters:
unit - The unit in which to express the minimal duration.
Returns:
The minimal duration in the given unit.

setMinDuration

@Configuration
public void setMinDuration(long duration,
                                         TimeUnit unit)
                    throws IllegalArgumentException
Sets the minimal duration for logging an event at this level. Invoking this method may have an indirect impact of other performance levels:

Note: The duration of the PERFORMANCE level can not be modified: it is always zero. However invoking this method on the PERFORMANCE field will ensure that every SLOW* levels will have at least the given duration.

Parameters:
duration - The minimal duration.
unit - The unit of the given duration value.
Throws:
IllegalArgumentException - If the given duration is negative.


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.