1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.monitor.api

File MonitorTimerSummary.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
20
8
1
84
53
8
0.4
2.5
8
1

Classes

Class Line # Actions
MonitorTimerSummary 22 20 0% 8 28
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.monitor.api;
21   
 
22    public class MonitorTimerSummary
23    {
24    private String name;
25   
26    private long duration = 0;
27   
28    private long nbcalls = 0;
29   
30    private long nbrequests = 0;
31   
 
32  0 toggle public MonitorTimerSummary(String name)
33    {
34  0 this.name = name;
35    }
36   
 
37  0 toggle public String getName()
38    {
39  0 return this.name;
40    }
41   
 
42  0 toggle public void addTimer(long duration)
43    {
44  0 this.duration += duration;
45  0 this.nbcalls++;
46  0 this.nbrequests = 1;
47    }
48   
 
49  0 toggle public long getDuration()
50    {
51  0 return this.duration;
52    }
53   
 
54  0 toggle public long getNbCalls()
55    {
56  0 return this.nbcalls;
57    }
58   
 
59  0 toggle public void add(MonitorTimerSummary stimer)
60    {
61  0 this.duration += stimer.getDuration();
62  0 this.nbcalls += stimer.getNbCalls();
63  0 this.nbrequests++;
64    }
65   
 
66  0 toggle public long getRequests()
67    {
68  0 return this.nbrequests;
69    }
70   
 
71  0 toggle @Override
72    public String toString()
73    {
74  0 StringBuffer str = new StringBuffer();
75  0 str.append(this.name);
76  0 str.append(": duration=");
77  0 str.append(getDuration());
78  0 str.append(" nbcalls=");
79  0 str.append(getNbCalls());
80  0 str.append(" nbrequests=");
81  0 str.append(getRequests());
82  0 return str.toString();
83    }
84    }