src/hotspot/share/gc/shared/gcTimer.cpp
changeset 52321 52d3bb5ba2f7
parent 50113 caf115bb98ad
--- a/src/hotspot/share/gc/shared/gcTimer.cpp	Mon Oct 29 13:58:29 2018 -0700
+++ b/src/hotspot/share/gc/shared/gcTimer.cpp	Mon Oct 29 14:04:42 2018 -0700
@@ -182,214 +182,3 @@
   assert(has_next(), "Must have phases left");
   return _time_partitions->phase_at(_next++);
 }
-
-
-/////////////// Unit tests ///////////////
-
-#ifndef PRODUCT
-
-class TimePartitionPhasesIteratorTest {
- public:
-  static void all() {
-    one_pause();
-    two_pauses();
-    one_sub_pause_phase();
-    many_sub_pause_phases();
-    many_sub_pause_phases2();
-    max_nested_pause_phases();
-    one_concurrent();
-  }
-
-  static void validate_gc_phase(GCPhase* phase, int level, const char* name, const Ticks& start, const Ticks& end) {
-    assert(phase->level() == level, "Incorrect level");
-    assert(strcmp(phase->name(), name) == 0, "Incorrect name");
-    assert(phase->start() == start, "Incorrect start");
-    assert(phase->end() == end, "Incorrect end");
-  }
-
-  static void one_pause() {
-    TimePartitions time_partitions;
-    time_partitions.report_gc_phase_start("PausePhase", 2);
-    time_partitions.report_gc_phase_end(8);
-
-    TimePartitionPhasesIterator iter(&time_partitions);
-
-    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 8);
-    assert(time_partitions.sum_of_pauses() == Ticks(8) - Ticks(2), "Incorrect");
-    assert(time_partitions.longest_pause() == Ticks(8) - Ticks(2), "Incorrect");
-
-    assert(!iter.has_next(), "Too many elements");
-  }
-
-  static void two_pauses() {
-    TimePartitions time_partitions;
-    time_partitions.report_gc_phase_start("PausePhase1", 2);
-    time_partitions.report_gc_phase_end(3);
-    time_partitions.report_gc_phase_start("PausePhase2", 4);
-    time_partitions.report_gc_phase_end(6);
-
-    TimePartitionPhasesIterator iter(&time_partitions);
-
-    validate_gc_phase(iter.next(), 0, "PausePhase1", 2, 3);
-    validate_gc_phase(iter.next(), 0, "PausePhase2", 4, 6);
-
-    assert(time_partitions.sum_of_pauses() == Ticks(3) - Ticks(0), "Incorrect");
-    assert(time_partitions.longest_pause() == Ticks(2) - Ticks(0), "Incorrect");
-
-    assert(!iter.has_next(), "Too many elements");
-  }
-
-  static void one_sub_pause_phase() {
-    TimePartitions time_partitions;
-    time_partitions.report_gc_phase_start("PausePhase", 2);
-    time_partitions.report_gc_phase_start("SubPhase", 3);
-    time_partitions.report_gc_phase_end(4);
-    time_partitions.report_gc_phase_end(5);
-
-    TimePartitionPhasesIterator iter(&time_partitions);
-
-    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 5);
-    validate_gc_phase(iter.next(), 1, "SubPhase", 3, 4);
-
-    assert(time_partitions.sum_of_pauses() == Ticks(3) - Ticks(0), "Incorrect");
-    assert(time_partitions.longest_pause() == Ticks(3) - Ticks(0), "Incorrect");
-
-    assert(!iter.has_next(), "Too many elements");
-  }
-
-  static void max_nested_pause_phases() {
-    TimePartitions time_partitions;
-    time_partitions.report_gc_phase_start("PausePhase", 2);
-    time_partitions.report_gc_phase_start("SubPhase1", 3);
-    time_partitions.report_gc_phase_start("SubPhase2", 4);
-    time_partitions.report_gc_phase_start("SubPhase3", 5);
-    time_partitions.report_gc_phase_end(6);
-    time_partitions.report_gc_phase_end(7);
-    time_partitions.report_gc_phase_end(8);
-    time_partitions.report_gc_phase_end(9);
-
-    TimePartitionPhasesIterator iter(&time_partitions);
-
-    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 9);
-    validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 8);
-    validate_gc_phase(iter.next(), 2, "SubPhase2", 4, 7);
-    validate_gc_phase(iter.next(), 3, "SubPhase3", 5, 6);
-
-    assert(time_partitions.sum_of_pauses() == Ticks(7) - Ticks(0), "Incorrect");
-    assert(time_partitions.longest_pause() == Ticks(7) - Ticks(0), "Incorrect");
-
-    assert(!iter.has_next(), "Too many elements");
-  }
-
-  static void many_sub_pause_phases() {
-    TimePartitions time_partitions;
-    time_partitions.report_gc_phase_start("PausePhase", 2);
-
-    time_partitions.report_gc_phase_start("SubPhase1", 3);
-    time_partitions.report_gc_phase_end(4);
-    time_partitions.report_gc_phase_start("SubPhase2", 5);
-    time_partitions.report_gc_phase_end(6);
-    time_partitions.report_gc_phase_start("SubPhase3", 7);
-    time_partitions.report_gc_phase_end(8);
-    time_partitions.report_gc_phase_start("SubPhase4", 9);
-    time_partitions.report_gc_phase_end(10);
-
-    time_partitions.report_gc_phase_end(11);
-
-    TimePartitionPhasesIterator iter(&time_partitions);
-
-    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 11);
-    validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 4);
-    validate_gc_phase(iter.next(), 1, "SubPhase2", 5, 6);
-    validate_gc_phase(iter.next(), 1, "SubPhase3", 7, 8);
-    validate_gc_phase(iter.next(), 1, "SubPhase4", 9, 10);
-
-    assert(time_partitions.sum_of_pauses() == Ticks(9) - Ticks(0), "Incorrect");
-    assert(time_partitions.longest_pause() == Ticks(9) - Ticks(0), "Incorrect");
-
-    assert(!iter.has_next(), "Too many elements");
-  }
-
-  static void many_sub_pause_phases2() {
-    TimePartitions time_partitions;
-    time_partitions.report_gc_phase_start("PausePhase", 2);
-
-    time_partitions.report_gc_phase_start("SubPhase1", 3);
-    time_partitions.report_gc_phase_start("SubPhase11", 4);
-    time_partitions.report_gc_phase_end(5);
-    time_partitions.report_gc_phase_start("SubPhase12", 6);
-    time_partitions.report_gc_phase_end(7);
-    time_partitions.report_gc_phase_end(8);
-    time_partitions.report_gc_phase_start("SubPhase2", 9);
-    time_partitions.report_gc_phase_start("SubPhase21", 10);
-    time_partitions.report_gc_phase_end(11);
-    time_partitions.report_gc_phase_start("SubPhase22", 12);
-    time_partitions.report_gc_phase_end(13);
-    time_partitions.report_gc_phase_end(14);
-    time_partitions.report_gc_phase_start("SubPhase3", 15);
-    time_partitions.report_gc_phase_end(16);
-
-    time_partitions.report_gc_phase_end(17);
-
-    TimePartitionPhasesIterator iter(&time_partitions);
-
-    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 17);
-    validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 8);
-    validate_gc_phase(iter.next(), 2, "SubPhase11", 4, 5);
-    validate_gc_phase(iter.next(), 2, "SubPhase12", 6, 7);
-    validate_gc_phase(iter.next(), 1, "SubPhase2", 9, 14);
-    validate_gc_phase(iter.next(), 2, "SubPhase21", 10, 11);
-    validate_gc_phase(iter.next(), 2, "SubPhase22", 12, 13);
-    validate_gc_phase(iter.next(), 1, "SubPhase3", 15, 16);
-
-    assert(time_partitions.sum_of_pauses() == Ticks(15) - Ticks(0), "Incorrect");
-    assert(time_partitions.longest_pause() == Ticks(15) - Ticks(0), "Incorrect");
-
-    assert(!iter.has_next(), "Too many elements");
-  }
-
-  static void one_concurrent() {
-    TimePartitions time_partitions;
-    time_partitions.report_gc_phase_start("ConcurrentPhase", 2, GCPhase::ConcurrentPhaseType);
-    time_partitions.report_gc_phase_end(8, GCPhase::ConcurrentPhaseType);
-
-    TimePartitionPhasesIterator iter(&time_partitions);
-
-    validate_gc_phase(iter.next(), 0, "ConcurrentPhase", 2, 8);
-    // ConcurrentPhaseType should not affect to both 'sum_of_pauses()' and 'longest_pause()'.
-    assert(time_partitions.sum_of_pauses() == Tickspan(), "Incorrect");
-    assert(time_partitions.longest_pause() == Tickspan(), "Incorrect");
-
-    assert(!iter.has_next(), "Too many elements");
-  }
-};
-
-class GCTimerTest {
-public:
-  static void all() {
-    gc_start();
-    gc_end();
-  }
-
-  static void gc_start() {
-    GCTimer gc_timer;
-    gc_timer.register_gc_start(1);
-
-    assert(gc_timer.gc_start() == Ticks(1), "Incorrect");
-  }
-
-  static void gc_end() {
-    GCTimer gc_timer;
-    gc_timer.register_gc_start(1);
-    gc_timer.register_gc_end(2);
-
-    assert(gc_timer.gc_end() == Ticks(2), "Incorrect");
-  }
-};
-
-void GCTimer_test() {
-  GCTimerTest::all();
-  TimePartitionPhasesIteratorTest::all();
-}
-
-#endif