avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/altprofile/profiler DefaultProfilerManager.java
Date Wed, 13 Mar 2002 07:05:09 GMT
leif        02/03/12 23:05:09

  Modified:    examples/altprofile/conf altprofile.desktop profiler.xml
               src/scratchpad/org/apache/avalon/excalibur/altprofile/profiler
                        DefaultProfilerManager.java
  Log:
  Add a ProfilePoint which tracks the number of active threads in the JVM.
  
  Revision  Changes    Path
  1.2       +5 -4      jakarta-avalon-excalibur/examples/altprofile/conf/altprofile.desktop
  
  Index: altprofile.desktop
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/examples/altprofile/conf/altprofile.desktop,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- altprofile.desktop	5 Mar 2002 09:41:41 -0000	1.1
  +++ altprofile.desktop	13 Mar 2002 07:05:08 -0000	1.2
  @@ -1,8 +1,9 @@
   <?xml version="1.0" encoding="UTF-8"?>
  -<profiler-frame height="555" x="13" width="1216" y="37">
  +<profiler-frame height="580" x="13" width="1211" y="37">
   <inner-frame height="120" x="0" type="sample-frame" width="600" sample="example-profilable.doaction-counter.counter.1000.600"
y="0"/>
   <inner-frame height="120" x="600" type="sample-frame" width="600" sample="profiler.total-memory.max.1000.600"
y="0"/>
  -<inner-frame height="120" x="601" type="sample-frame" width="600" sample="profiler.memory.max.1000.600"
y="120"/>
  -<inner-frame height="120" x="1" type="sample-frame" width="600" sample="example-profilable.counter-quick.counter.1000.600"
y="120"/>
  -<inner-frame height="212" x="1" type="sample-frame" width="1200" sample="example-profilable.random-random.minimum.1000.600"
y="240"/>
  +<inner-frame height="120" x="0" type="sample-frame" width="600" sample="example-profilable.counter-quick.counter.1000.600"
y="120"/>
  +<inner-frame height="120" x="600" type="sample-frame" width="600" sample="profiler.memory.max.1000.600"
y="120"/>
  +<inner-frame height="120" x="-1" type="sample-frame" width="600" sample="example-profilable.random-random.minimum.1000.600"
y="240"/>
  +<inner-frame height="120" x="599" type="sample-frame" width="600" sample="profiler.active-thread-count.max.1000.600"
y="240"/>
   </profiler-frame>
  
  
  
  1.4       +3 -0      jakarta-avalon-excalibur/examples/altprofile/conf/profiler.xml
  
  Index: profiler.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/examples/altprofile/conf/profiler.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- profiler.xml	6 Mar 2002 06:44:45 -0000	1.3
  +++ profiler.xml	13 Mar 2002 07:05:08 -0000	1.4
  @@ -4,6 +4,9 @@
       <profilables>
           <!-- The profiler Profilable is the ProfilerManager itself. -->
           <profilable name="profiler" description="Profiler">
  +            <profile-point name="active-thread-count" description="Active Thread Count">
  +                <sample type="max" interval="1000" size="600" description="Maximum each
second."/>
  +            </profile-point>
               
               <profile-point name="total-memory" description="Total Memory">
                   <sample type="max" interval="1000" size="600" description="Maximum each
second."/>
  
  
  
  1.7       +28 -2     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/altprofile/profiler/DefaultProfilerManager.java
  
  Index: DefaultProfilerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/altprofile/profiler/DefaultProfilerManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultProfilerManager.java	6 Mar 2002 06:45:04 -0000	1.6
  +++ DefaultProfilerManager.java	13 Mar 2002 07:05:09 -0000	1.7
  @@ -36,7 +36,7 @@
   /**
    *
    * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2002/03/06 06:45:04 $
  + * @version CVS $Revision: 1.7 $ $Date: 2002/03/13 07:05:09 $
    * @since 4.1
    */
   public class DefaultProfilerManager
  @@ -46,6 +46,7 @@
       public static final String PROFILE_POINT_TOTAL_MEMORY = "total-memory";
       public static final String PROFILE_POINT_FREE_MEMORY = "free-memory";
       public static final String PROFILE_POINT_MEMORY = "memory";
  +    public static final String PROFILE_POINT_ACTIVE_THREAD_COUNT = "active-thread-count";
       
       /** Configuration for the ProfileManager */
       private Configuration m_configuration;
  @@ -92,6 +93,9 @@
       /** ProfilePoint used to profile the in use memory. */
       private ValueProfilePoint m_memoryProfilePoint;
       
  +    /** ProfilePoint used to profile the active thread count of the JVM. */
  +    private ValueProfilePoint m_activeThreadCountProfilePoint;
  +    
       /*---------------------------------------------------------------
        * Constructors
        *-------------------------------------------------------------*/
  @@ -101,6 +105,7 @@
           m_totalMemoryProfilePoint = new ValueProfilePoint( PROFILE_POINT_TOTAL_MEMORY );
           m_freeMemoryProfilePoint = new ValueProfilePoint( PROFILE_POINT_FREE_MEMORY );
           m_memoryProfilePoint = new ValueProfilePoint( PROFILE_POINT_MEMORY );
  +        m_activeThreadCountProfilePoint = new ValueProfilePoint( PROFILE_POINT_ACTIVE_THREAD_COUNT
);
       }
       
       /*---------------------------------------------------------------
  @@ -470,7 +475,8 @@
           {
               m_totalMemoryProfilePoint,
               m_freeMemoryProfilePoint,
  -            m_memoryProfilePoint
  +            m_memoryProfilePoint,
  +            m_activeThreadCountProfilePoint
           };
       }
   
  @@ -500,6 +506,7 @@
                   Thread.sleep( 1000 );
                   
                   memoryProfilePoints();
  +                threadProfilePoints();
                   
                   // Handle the state file if it is set
                   long now = System.currentTimeMillis();
  @@ -649,6 +656,25 @@
                   freeMemory = runtime.freeMemory();
               }
               m_memoryProfilePoint.setValue( (int)(totalMemory - freeMemory) );
  +        }
  +    }
  +    
  +    /**
  +     * Updates the Thread based Profile Points published by the ProfilerManager.
  +     */
  +    private void threadProfilePoints()
  +    {
  +        if ( m_activeThreadCountProfilePoint.isActive() )
  +        {
  +            // Get the top level thread group.
  +            ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
  +            ThreadGroup parent;
  +            while ( ( parent = threadGroup.getParent() ) != null )
  +            {
  +                threadGroup = parent;
  +            }
  +            
  +            m_activeThreadCountProfilePoint.setValue( threadGroup.activeCount() );
           }
       }
       
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message