KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > profile > EventsPerSampleProfilePoint


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package org.apache.avalon.excalibur.profile;
9
10 /**
11  * The ProfilPoint interface is to mark objects that can be sampled by a
12  * Profiler. The interface only has one sampling method to simplify the items
13  * that can be sampled.
14  *
15  * @author <a HREF="mailto:bloritsch@apache.org">Berin Loritsch</a>
16  */

17 public class EventsPerSampleProfilePoint extends AbstractProfilePoint
18 {
19     private int m_value = 0;
20
21     /**
22      * Creates a EventsPerSampleProfilePoint with an initial name.
23      */

24     public EventsPerSampleProfilePoint( String JavaDoc name )
25     {
26         super( name );
27     }
28
29     /**
30      * Set the sample value
31      */

32     public void increment( )
33     {
34         m_value++;
35     }
36
37     /**
38      * Obtain the sample. All samples are an integer, so the profiled objects
39      * must measure quantity (numbers of items), rate (items/period), time in
40      * milliseconds, etc.
41      */

42     public int getSample()
43     {
44         final int returnValue = m_value;
45         m_value = 0;
46
47         return returnValue;
48     }
49 }
50
Popular Tags