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 #include "precompiled.hpp"
26 #include "gc_implementation/shared/gcTimer.hpp"
27 #include "utilities/growableArray.hpp"
28 #include "utilities/ticks.inline.hpp"
29
30 // the "time" parameter for most functions
31 // has a default value set by Ticks::now()
32
33 void GCTimer::register_gc_start(const Ticks& time) {
34 _time_partitions.clear();
35 _gc_start = time;
36 }
37
38 void GCTimer::register_gc_end(const Ticks& time) {
39 assert(!_time_partitions.has_active_phases(),
40 "We should have ended all started phases, before ending the GC");
41
42 _gc_end = time;
43 }
44
45 void GCTimer::register_gc_pause_start(const char* name, const Ticks& time) {
46 _time_partitions.report_gc_phase_start(name, time);
47 }
48
332 validate_pause_phase(iter.next(), 1, "SubPhase3", 15, 16);
333
334 assert(time_partitions.sum_of_pauses() == Ticks(15) - Ticks(0), "Incorrect");
335 assert(time_partitions.longest_pause() == Ticks(15) - Ticks(0), "Incorrect");
336
337 assert(!iter.has_next(), "Too many elements");
338 }
339 };
340
341 class GCTimerTest {
342 public:
343 static void all() {
344 gc_start();
345 gc_end();
346 }
347
348 static void gc_start() {
349 GCTimer gc_timer;
350 gc_timer.register_gc_start(1);
351
352 assert(gc_timer.gc_start() == 1, "Incorrect");
353 }
354
355 static void gc_end() {
356 GCTimer gc_timer;
357 gc_timer.register_gc_start(1);
358 gc_timer.register_gc_end(2);
359
360 assert(gc_timer.gc_end() == 2, "Incorrect");
361 }
362 };
363
364 void GCTimerAllTest::all() {
365 GCTimerTest::all();
366 TimePartitionPhasesIteratorTest::all();
367 }
368
369 #endif
|
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 #include "precompiled.hpp"
26 #include "gc_implementation/shared/gcTimer.hpp"
27 #include "utilities/growableArray.hpp"
28 #include "utilities/ticks.hpp"
29
30 // the "time" parameter for most functions
31 // has a default value set by Ticks::now()
32
33 void GCTimer::register_gc_start(const Ticks& time) {
34 _time_partitions.clear();
35 _gc_start = time;
36 }
37
38 void GCTimer::register_gc_end(const Ticks& time) {
39 assert(!_time_partitions.has_active_phases(),
40 "We should have ended all started phases, before ending the GC");
41
42 _gc_end = time;
43 }
44
45 void GCTimer::register_gc_pause_start(const char* name, const Ticks& time) {
46 _time_partitions.report_gc_phase_start(name, time);
47 }
48
332 validate_pause_phase(iter.next(), 1, "SubPhase3", 15, 16);
333
334 assert(time_partitions.sum_of_pauses() == Ticks(15) - Ticks(0), "Incorrect");
335 assert(time_partitions.longest_pause() == Ticks(15) - Ticks(0), "Incorrect");
336
337 assert(!iter.has_next(), "Too many elements");
338 }
339 };
340
341 class GCTimerTest {
342 public:
343 static void all() {
344 gc_start();
345 gc_end();
346 }
347
348 static void gc_start() {
349 GCTimer gc_timer;
350 gc_timer.register_gc_start(1);
351
352 assert(gc_timer.gc_start() == Ticks(1), "Incorrect");
353 }
354
355 static void gc_end() {
356 GCTimer gc_timer;
357 gc_timer.register_gc_start(1);
358 gc_timer.register_gc_end(2);
359
360 assert(gc_timer.gc_end() == Ticks(2), "Incorrect");
361 }
362 };
363
364 void GCTimerAllTest::all() {
365 GCTimerTest::all();
366 TimePartitionPhasesIteratorTest::all();
367 }
368
369 #endif
|