org.nuiton.util
Class TimeTrace

java.lang.Object
  extended by org.nuiton.util.TimeTrace

public class TimeTrace
extends Object

Cette classe permet de facilement trace le temps d'execution entre deux points usage

 TimeTrace timeTrace = new TimeTrace(5000, 1000);


 long start = timeTrace.getTime();
 ...
 // do some work
 ...
 timeTrace.add(start, "do some work");


 System.out.println ("time: " + timeTrace.getCallCount());
 

Version:
$Revision: 1985 $ Last update: $Date: 2010-12-23 12:45:57 +0100 (Thu, 23 Dec 2010) $ by : $Author: sletellier $
Author:
poussin
See Also:
CallAnalyse

Nested Class Summary
static class TimeTrace.CallStat
           
 
Field Summary
protected  Map<String,TimeTrace.CallStat> callCount
          for each method of all proxies, keep number of call
protected  long timeToLogInfo
          time to trigger log time in info level (ns) (default: 1s)
protected  long timeToLogWarn
          time to trigger log time in warn level (ns) (default: 3s)
 
Constructor Summary
TimeTrace()
           
TimeTrace(long timeToLogInfo, long timeToLogWarn)
           
 
Method Summary
 void add(long startNs, long stopNs, String methodName)
          add new trace
 void add(long startNs, String methodName)
          add new trace, stop time is automaticaly computed
 Map<String,TimeTrace.CallStat> getCallCount()
           
static long getTime()
          return time in format acceptable for #add(timeToLogInfo, timeToLogInfo, null)
 void setTimeToLogInfo(long timeToLogInfoMs)
           
 void setTimeToLogWarn(long timeToLogWarnMs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeToLogInfo

protected long timeToLogInfo
time to trigger log time in info level (ns) (default: 1s)


timeToLogWarn

protected long timeToLogWarn
time to trigger log time in warn level (ns) (default: 3s)


callCount

protected Map<String,TimeTrace.CallStat> callCount
for each method of all proxies, keep number of call

Constructor Detail

TimeTrace

public TimeTrace()

TimeTrace

public TimeTrace(long timeToLogInfo,
                 long timeToLogWarn)
Parameters:
timeToLogInfo - time in milliseconde after that we log info
timeToLogWarn - time in milliseconde after that we log warn
Method Detail

setTimeToLogInfo

public void setTimeToLogInfo(long timeToLogInfoMs)
Parameters:
timeToLogInfoMs - time in milliseconde after that we log info

setTimeToLogWarn

public void setTimeToLogWarn(long timeToLogWarnMs)
Parameters:
timeToWarnInfoMs - time in milliseconde after that we log warn

getCallCount

public Map<String,TimeTrace.CallStat> getCallCount()

getTime

public static long getTime()
return time in format acceptable for #add(timeToLogInfo, timeToLogInfo, null)

Returns:

add

public void add(long startNs,
                String methodName)
add new trace, stop time is automaticaly computed

Parameters:
startNs - time returned by getTime() method
methodName - key name to store this time

add

public void add(long startNs,
                long stopNs,
                String methodName)
add new trace

Parameters:
startNs - time returned by getTime() method
stopNs - time returned by getTime() method
methodName - key name to store this time


Copyright © 2004-2010 CodeLutin. All Rights Reserved.