org.nuiton.profiling
Class NuitonTrace

java.lang.Object
  extended by org.nuiton.profiling.NuitonTrace

public class NuitonTrace
extends Object

Permet de tracer les appels aux methodes.

Pour l'utiliser il faut définir un fichier XML qui intercepte les methodes souhaiter.

 <?xml version="1.0" encoding="ISO-8859-1"?>
 

<!DOCTYPE aspectwerkz PUBLIC "-//AspectWerkz//DTD//EN" "http://aspectwerkz.codehaus.org/dtd/aspectwerkz2.dtd">

<aspectwerkz> <system id="sample"> <aspect class="fr.ifremer.isisfish.aspect.TraceIsis"> <pointcut name="executeMethod"> execution(* fr.ifremer.isisfish.datastore.ResultStorage.*(..)) || execution(* fr.ifremer.isisfish.aspect.Cache.*(..)) || execution(* fr.ifremer.isisfish.aspect.Trace.*(..)) || execution(* org.nuiton.topia..*(..)) || execution(* org.nuiton.math.matrix..*(..)) || execution(* fr.ifremer.isisfish.types..*(..)) || execution(* org.apache.commons.collections..*(..)) </pointcut> </aspect> </system> </aspectwerkz>

Ensuite il faut lancer la JVM avec deux options
  • -javaagent:path/to/aspectwerkz-jdk5-2.0.jar
  • -Daspectwerkz.definition.file=path/to/trace-aop.xml

    il doit être possible d'utiliser des noms normalisé et trouvable dans le classpath a la place de -Daspectwerkz.definition.file

  • /aspectwerkz.xml
  • META-INF/aop.xml
  • WEB-INF/aop.xml

    Ensuite pour afficher les statistiques dans votre programme

  • log.info(NuitonTrace.getStatisticsAndClear());
  • NuitonTrace.printStatistiqueAndClear();

    Il doit être possible, plutot que d'écrire un fichier XML, de sous classer NuitonTrace en ajoutant par exemple

    Author:
    poussin

    Field Summary
    protected  Stack<long[]> callStack
              array : [nest method call, start time, start time with child]
    static int STAT_CALL
              nombre d'appel
    static int STAT_CALL_NEST_METHOD
              nombre d'appel vers une autre method depuis cette methode
    static int STAT_TIME_MAX
              temps max d'execution de cette methode (sans le temps des autres methodes)
    static int STAT_TIME_MIN
              temps mini d'execution de cette methode (sans le temps des autres methodes)
    static int STAT_TIME_TOTAL
              temps total d'execution de cette methode (sans le temps des autres methodes)
    static int STAT_TIME_TOTAL_NEST_METHOD
              temps total d'execution de cette methode (avec le temps des autres methodes)
    protected  Map<Method,long[]> statistics
              array : [call's numbers, call do, min time, max time, total time, total time with child]
     
    Constructor Summary
    NuitonTrace()
               
     
    Method Summary
     long[] getStatistics(Method method)
               
    static String getStatisticsAndClear()
               
    static void printStatisticsAndClear()
               
    static void printStatisticsAndClear(PrintStream printer)
               
     void traceAfterExecute(org.codehaus.aspectwerkz.joinpoint.JoinPoint jp)
               
     void traceAfterThrowingExecute(org.codehaus.aspectwerkz.joinpoint.JoinPoint jp)
               
     void traceBeforeExecute(org.codehaus.aspectwerkz.joinpoint.JoinPoint jp)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    STAT_CALL

    public static final int STAT_CALL
    nombre d'appel

    See Also:
    Constant Field Values

    STAT_CALL_NEST_METHOD

    public static final int STAT_CALL_NEST_METHOD
    nombre d'appel vers une autre method depuis cette methode

    See Also:
    Constant Field Values

    STAT_TIME_MIN

    public static final int STAT_TIME_MIN
    temps mini d'execution de cette methode (sans le temps des autres methodes)

    See Also:
    Constant Field Values

    STAT_TIME_MAX

    public static final int STAT_TIME_MAX
    temps max d'execution de cette methode (sans le temps des autres methodes)

    See Also:
    Constant Field Values

    STAT_TIME_TOTAL

    public static final int STAT_TIME_TOTAL
    temps total d'execution de cette methode (sans le temps des autres methodes)

    See Also:
    Constant Field Values

    STAT_TIME_TOTAL_NEST_METHOD

    public static final int STAT_TIME_TOTAL_NEST_METHOD
    temps total d'execution de cette methode (avec le temps des autres methodes)

    See Also:
    Constant Field Values

    statistics

    protected Map<Method,long[]> statistics
    array : [call's numbers, call do, min time, max time, total time, total time with child]


    callStack

    protected Stack<long[]> callStack
    array : [nest method call, start time, start time with child]

    Constructor Detail

    NuitonTrace

    public NuitonTrace()
    Method Detail

    getStatistics

    public long[] getStatistics(Method method)

    traceBeforeExecute

    public void traceBeforeExecute(org.codehaus.aspectwerkz.joinpoint.JoinPoint jp)

    traceAfterThrowingExecute

    public void traceAfterThrowingExecute(org.codehaus.aspectwerkz.joinpoint.JoinPoint jp)

    traceAfterExecute

    public void traceAfterExecute(org.codehaus.aspectwerkz.joinpoint.JoinPoint jp)

    getStatisticsAndClear

    public static String getStatisticsAndClear()
    Returns:
    les statistiques

    printStatisticsAndClear

    public static void printStatisticsAndClear()

    printStatisticsAndClear

    public static void printStatisticsAndClear(PrintStream printer)


    Copyright © 2006-2010 CodeLutin. All Rights Reserved.