1 /*
2 * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 // Catch-all file for utility classes
26
27 // A weighted average maintains a running, weighted average
28 // of some float value (templates would be handy here if we
29 // need different types).
30 //
31 // The average is adaptive in that we smooth it for the
32 // initial samples; we don't use the weight until we have
33 // enough samples for it to be meaningful.
34 //
35 // This serves as our best estimate of a future unknown.
36 //
37 class AdaptiveWeightedAverage : public CHeapObj {
38 private:
39 float _average; // The last computed average
40 unsigned _sample_count; // How often we've sampled this average
41 unsigned _weight; // The weight used to smooth the averages
42 // A higher weight favors the most
43 // recent data.
44
189 double y(double x);
190 double slope() { return _slope; }
191 // Methods to decide if a change in the dependent variable will
192 // achive a desired goal. Note that these methods are not
193 // complementary and both are needed.
194 bool decrement_will_decrease();
195 bool increment_will_decrease();
196 };
197
198 class GCPauseTimer : StackObj {
199 elapsedTimer* _timer;
200 public:
201 GCPauseTimer(elapsedTimer* timer) {
202 _timer = timer;
203 _timer->stop();
204 }
205 ~GCPauseTimer() {
206 _timer->start();
207 }
208 };
|
1 /*
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_GCUTIL_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_GCUTIL_HPP
27
28 #include "memory/allocation.hpp"
29 #include "runtime/timer.hpp"
30 #include "utilities/debug.hpp"
31 #include "utilities/globalDefinitions.hpp"
32 #include "utilities/ostream.hpp"
33
34 // Catch-all file for utility classes
35
36 // A weighted average maintains a running, weighted average
37 // of some float value (templates would be handy here if we
38 // need different types).
39 //
40 // The average is adaptive in that we smooth it for the
41 // initial samples; we don't use the weight until we have
42 // enough samples for it to be meaningful.
43 //
44 // This serves as our best estimate of a future unknown.
45 //
46 class AdaptiveWeightedAverage : public CHeapObj {
47 private:
48 float _average; // The last computed average
49 unsigned _sample_count; // How often we've sampled this average
50 unsigned _weight; // The weight used to smooth the averages
51 // A higher weight favors the most
52 // recent data.
53
198 double y(double x);
199 double slope() { return _slope; }
200 // Methods to decide if a change in the dependent variable will
201 // achive a desired goal. Note that these methods are not
202 // complementary and both are needed.
203 bool decrement_will_decrease();
204 bool increment_will_decrease();
205 };
206
207 class GCPauseTimer : StackObj {
208 elapsedTimer* _timer;
209 public:
210 GCPauseTimer(elapsedTimer* timer) {
211 _timer = timer;
212 _timer->stop();
213 }
214 ~GCPauseTimer() {
215 _timer->start();
216 }
217 };
218
219 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GCUTIL_HPP
|