Commit | Line | Data |
---|---|---|
79e08fd0 | 1 | /******************************************************************************* |
b544077e | 2 | * Copyright (c) 2011, 2012 Ericsson |
013a5f1c | 3 | * |
79e08fd0 BH |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
013a5f1c | 8 | * |
79e08fd0 | 9 | * Contributors: |
09667aa4 | 10 | * Mathieu Denis <mathieu.denis@polymtl.ca> - Intial API and Implementation |
79e08fd0 BH |
11 | *******************************************************************************/ |
12 | ||
cfd22ad0 | 13 | package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model; |
79e08fd0 BH |
14 | |
15 | /** | |
013a5f1c AM |
16 | * Primitive container for Statistics data |
17 | * | |
09667aa4 MD |
18 | * Contains information about statistics that can be retrieved with any type of |
19 | * traces | |
013a5f1c | 20 | * |
25a042b3 MD |
21 | * There are two counters : one for the total number of events in the trace and |
22 | * another for the number of events in the selected time range | |
23 | * | |
24 | * @version 2.0 | |
cfd22ad0 MD |
25 | * @version 2.0 |
26 | * @since 2.0 | |
b544077e | 27 | * @author Mathieu Denis |
79e08fd0 BH |
28 | */ |
29 | public class TmfStatistics { | |
cfd22ad0 | 30 | |
09667aa4 | 31 | /** |
25a042b3 MD |
32 | * Total number of events. |
33 | * | |
34 | * @since 2.0 | |
35 | */ | |
36 | protected long fNbEvents = 0; | |
cfd22ad0 | 37 | |
25a042b3 MD |
38 | /** |
39 | * Number of events within a time range (Partial event count). | |
40 | * | |
41 | * @since 2.0 | |
42 | */ | |
43 | protected long fNbEventsInTimeRange = 0; | |
44 | ||
45 | /** | |
46 | * @return the total events count | |
47 | * @since 2.0 | |
48 | */ | |
49 | public long getTotal() { | |
50 | return fNbEvents; | |
51 | } | |
52 | ||
53 | /** | |
54 | * @return the partial events count within a time range | |
55 | * @since 2.0 | |
56 | */ | |
57 | public long getPartial() { | |
58 | return fNbEventsInTimeRange; | |
59 | } | |
60 | ||
61 | /** | |
62 | * Increments by one the total number of events. | |
63 | * | |
64 | * @since 2.0 | |
65 | */ | |
66 | public void incrementTotal() { | |
67 | ++fNbEvents; | |
68 | } | |
69 | ||
70 | /** | |
71 | * Increments <b>nb</b> times the total number of events. | |
72 | * | |
73 | * @param nb | |
74 | * Amount that will be added to the total events count. Ignored | |
75 | * if negative. | |
76 | * @since 2.0 | |
77 | */ | |
78 | public void incrementTotal(int nb) { | |
79 | if (nb > 0) { | |
80 | fNbEvents += nb; | |
81 | } | |
82 | } | |
83 | ||
84 | /** | |
85 | * Increments by one the number of events within a time range (partial events | |
86 | * count). | |
87 | * | |
88 | * @since 2.0 | |
89 | */ | |
90 | public void incrementPartial() { | |
91 | ++fNbEventsInTimeRange; | |
92 | } | |
93 | ||
94 | /** | |
95 | * Increments <b>nb</b> times the number of events within a time range | |
96 | * (partial events count). | |
97 | * | |
98 | * @param nb | |
99 | * Amount that will be added to the partial events count. Ignored | |
100 | * if negative. | |
101 | * @since 2.0 | |
102 | */ | |
103 | public void incrementPartial(int nb) { | |
104 | if (nb > 0) { | |
105 | fNbEventsInTimeRange += nb; | |
106 | } | |
107 | } | |
108 | ||
109 | /** | |
110 | * Resets the total number of events. | |
111 | * | |
112 | * @since 2.0 | |
113 | */ | |
114 | public void resetTotalCount() { | |
115 | fNbEvents = 0; | |
116 | } | |
117 | ||
118 | /** | |
119 | * Resets the number of events within a time range (partial events count). | |
120 | * | |
121 | * @since 2.0 | |
09667aa4 | 122 | */ |
25a042b3 MD |
123 | public void resetPartialCount() { |
124 | fNbEventsInTimeRange = 0; | |
125 | } | |
79e08fd0 | 126 | } |