bloritsch    01/12/12 13:58:52

  Modified:    src/proposal/profile Profilable.java Profiler.java
  Added:       src/proposal/profile AbstractProfilePoint.java
                        EventsPerSampleProfilePoint.java
                        PeakValueProfilePoint.java ProfilePoint.java
                        ValueProfilePoint.java
  Log:
  Incorporating ideas from the discussion with Pete Royal
  
  Revision  Changes    Path
  1.2       +27 -7     jakarta-avalon/src/proposal/profile/Profilable.java
  
  Index: Profilable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/proposal/profile/Profilable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Profilable.java   2001/12/12 14:57:09     1.1
  +++ Profilable.java   2001/12/12 21:58:52     1.2
  @@ -9,16 +9,36 @@
   
   /**
    * The Profilable interface is to mark objects that can be sampled by a 
Profiler.
  - * The interface only has one method to simplify the items that can be 
sampled.
  + * The interface provides a method to initialize the profiler, plus two 
methods
  + * to provide an optimization cue for the object (when it is safe not to 
track
  + * events).
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
    */
  -interface Profilable
  +public interface Profilable
   {
       /**
  -     * Obtain the sample.  All samples are an integer, so the profiled 
objects
  -     * must measure quantity (numbers of items), rate (items/period), time in
  -     * milliseconds, etc.
  +     * Obtain a reference to all the ProfilePoints that the Profilable
  +     * object wishes to expose.  All sampling is done directly through
  +     * the ProfilePoints as opposed to the Profilable interface.
        */
  -    int getSample();
  -}
  \ No newline at end of file
  +    ProfilePoint[] getProfilePoints();
  +
  +    /**
  +     * The Profiler will call this method when it begins taking samples.
  +     * This is an optimization cue to the Profilable class.  It does take
  +     * resources to hold ProfilePoints and update them.  A class may keep
  +     * a <code>boolean</code> to flag whether the ProfilePoints are to be
  +     * maintained.
  +     */
  +    void startProfiling();
  +
  +    /**
  +     * The Profiler will call this method when it no longer is interested
  +     * in taking samples.  It is an optimization cue to the Profilable
  +     * class so that it can release resources and stop maintaining the
  +     * ProfilePoints.
  +     */
  +    void stopProfiling();
  +}
  +
  
  
  
  1.2       +4 -10     jakarta-avalon/src/proposal/profile/Profiler.java
  
  Index: Profiler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/proposal/profile/Profiler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Profiler.java     2001/12/12 14:57:09     1.1
  +++ Profiler.java     2001/12/12 21:58:52     1.2
  @@ -23,23 +23,17 @@
   public interface Profiler
   {
       /**
  -     * Tests wether the Profiler is active for the system.
  -     *
  -     * @returns <code>true</code> if Profiler is on, <code>false</code> if 
it is off.
  -     */
  -    boolean isRunning();
  -
  -    /**
        * Adds a target to profile, along with a name for the target.  Good 
names
        * include what the expected samples are.  For instance 
"ThreadController:
        * number of threads" or "EventQueue: events processed per second".  The 
real
        * results come from the Profilable object itself, but the name is so 
humans
  -     * have a reference for the values.
  +     * have a reference for the values.  NOTE: if the Profilable class does
  +     * not expose any ProfilePoints, it is excluded from the list of 
Profilable
  +     * classes that are notified when the Profiler is active.
        *
  -     * @parameter  name           The name of the sample type
        * @parameter  profileSource  The actual source of the samples
        */
  -    void add( String name, Profilable profileSource );
  +    void add( Profilable profileSource );
   
       /**
        * Serializes the results of the profiling to a file.  The actual format
  
  
  
  1.1                  
jakarta-avalon/src/proposal/profile/AbstractProfilePoint.java
  
  Index: AbstractProfilePoint.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.framework.profile;
  
  /**
   * The ProfilPoint interface is to mark objects that can be sampled by a
   * Profiler. The interface only has one sampling method to simplify the items
   * that can be sampled.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
   */
  public class AbstractProfilePoint implements ProfilePoint
  {
      private final String m_name;
  
      /**
       * Creates a MaxValueProfilePoint with an initial name.
       */
      public AbstractProfilePoint( String name )
      {
          m_name = name;
      }
  
      /**
       * Get the ProfilePoint's name.  The Profiler uses this so that the
       * heading for the sample data makes sense.
       */
      public final String getName()
      {
          return m_name;
      }
  }
  
  
  
  1.1                  
jakarta-avalon/src/proposal/profile/EventsPerSampleProfilePoint.java
  
  Index: EventsPerSampleProfilePoint.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.framework.profile;
  
  /**
   * The ProfilPoint interface is to mark objects that can be sampled by a
   * Profiler. The interface only has one sampling method to simplify the items
   * that can be sampled.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
   */
  public class EventsPerSampleProfilePoint extends AbstractProfilePoint
  {
      private       int    m_value = 0;
  
      /**
       * Creates a MaxValueProfilePoint with an initial name.
       */
      public PeakValueProfilePoint( String name )
      {
          super( name );
      }
  
      /**
       * Set the sample value
       */
      public void increment( )
      {
          m_value++;
      }
  
      /**
       * Obtain the sample.  All samples are an integer, so the profiled objects
       * must measure quantity (numbers of items), rate (items/period), time in
       * milliseconds, etc.
       */
      public int getSample()
      {
          final int returnValue = m_value;
          m_value = 0;
  
          return returnValue;
      }
  }
  
  
  
  1.1                  
jakarta-avalon/src/proposal/profile/PeakValueProfilePoint.java
  
  Index: PeakValueProfilePoint.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.framework.profile;
  
  /**
   * The ProfilPoint interface is to mark objects that can be sampled by a
   * Profiler. The interface only has one sampling method to simplify the items
   * that can be sampled.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
   */
  public class PeakValueProfilePoint extends AbstractProfilePoint
  {
      private       int    m_value = 0;
  
      /**
       * Creates a MaxValueProfilePoint with an initial name.
       */
      public PeakValueProfilePoint( String name )
      {
          super( name );
      }
  
      /**
       * Set the sample value
       */
      public void setValue( int currentValue )
      {
          if ( currentValue > m_value )
          {
              m_value = currentValue;
          }
      }
  
      /**
       * Obtain the sample.  All samples are an integer, so the profiled objects
       * must measure quantity (numbers of items), rate (items/period), time in
       * milliseconds, etc.
       */
      public int getSample()
      {
          return m_value;
      }
  }
  
  
  
  1.1                  jakarta-avalon/src/proposal/profile/ProfilePoint.java
  
  Index: ProfilePoint.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.framework.profile;
  
  /**
   * The ProfilPoint interface is to mark objects that can be sampled by a
   * Profiler. The interface only has one sampling method to simplify the items
   * that can be sampled.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
   */
  public interface ProfilePoint
  {
      /**
       * Get the ProfilePoint's name.  The Profiler uses this so that the
       * heading for the sample data makes sense.
       */
      String getName();
  
      /**
       * Obtain the sample.  All samples are an integer, so the profiled objects
       * must measure quantity (numbers of items), rate (items/period), time in
       * milliseconds, etc.
       */
      int getSample();
  }
  
  
  
  1.1                  
jakarta-avalon/src/proposal/profile/ValueProfilePoint.java
  
  Index: ValueProfilePoint.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.framework.profile;
  
  /**
   * The ProfilPoint interface is to mark objects that can be sampled by a
   * Profiler. The interface only has one sampling method to simplify the items
   * that can be sampled.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
   */
  public class ValueProfilePoint extends AbstractProfilePoint
  {
      private       int    m_value = 0;
  
      /**
       * Creates a MaxValueProfilePoint with an initial name.
       */
      public ValueProfilePoint( String name )
      {
          super( name );
      }
  
      /**
       * Set the sample value
       */
      public void setValue( int currentValue )
      {
          m_value = currentValue;
      }
  
      /**
       * Obtain the sample.  All samples are an integer, so the profiled objects
       * must measure quantity (numbers of items), rate (items/period), time in
       * milliseconds, etc.
       */
      public int getSample()
      {
          return m_value;
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to