Source code: org/activemq/perf/PerfRate.java
1 /**
2 * <a href="http://activemq.org">ActiveMQ: The Open Source Message Fabric</a>
3 *
4 * Copyright 2005 (C) Simula Labs Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
12 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 * specific language governing permissions and limitations under the License.
14 *
15 */
16 package org.activemq.perf;
17
18 /**
19 * @version $Revision: 1.3 $
20 */
21 public class PerfRate{
22 protected int totalCount;
23 protected int count;
24 protected long startTime=System.currentTimeMillis();
25 /**
26 * @return Returns the count.
27 */
28 public int getCount(){
29 return totalCount;
30 }
31 public void increment(){
32 totalCount++;
33 count++;
34 }
35 public void start(){
36 count=0;
37 startTime=System.currentTimeMillis();
38 }
39 public int getRate(){
40 long endTime=System.currentTimeMillis();
41 long totalTime=endTime-startTime;
42 int result=(int) ((count*1000)/totalTime);
43 return result;
44 }
45 /**
46 * @return Returns the totalCount.
47 */
48 public int getTotalCount(){
49 return totalCount;
50 }
51 /**
52 * @param totalCount
53 * The totalCount to set.
54 */
55 public void setTotalCount(int totalCount){
56 this.totalCount=totalCount;
57 }
58 }