995 return _buffer; 996 } 997 }; 998 999 public: 1000 ZStatTablePrinter(size_t column0_width, size_t columnN_width) : 1001 _column0_width(column0_width), 1002 _columnN_width(columnN_width) {} 1003 1004 ZColumn operator()() { 1005 return ZColumn(_buffer, 0, _column0_width, _columnN_width); 1006 } 1007 }; 1008 1009 // 1010 // Stat cycle 1011 // 1012 uint64_t ZStatCycle::_ncycles = 0; 1013 Ticks ZStatCycle::_start_of_last; 1014 Ticks ZStatCycle::_end_of_last; 1015 NumberSeq ZStatCycle::_duration(0.3 /* alpha */); 1016 1017 void ZStatCycle::at_start() { 1018 _start_of_last = Ticks::now(); 1019 } 1020 1021 void ZStatCycle::at_end(double boost_factor) { 1022 _end_of_last = Ticks::now(); 1023 _ncycles++; 1024 1025 // Calculate cycle duration. The duration is normalized using the boost 1026 // factor to avoid artificial deflation of the duration when boost mode 1027 // is enabled. 1028 const double duration = TicksToTimeHelper::seconds(_end_of_last - _start_of_last); 1029 const double normalized_duration = duration * boost_factor; 1030 _duration.add(normalized_duration); 1031 } 1032 1033 uint64_t ZStatCycle::ncycles() { 1034 return _ncycles; 1035 } 1036 1037 const AbsSeq& ZStatCycle::duration() { 1038 return _duration; 1039 } 1040 1041 double ZStatCycle::time_since_last() { 1042 if (_ncycles == 0) { 1043 // Return time since VM start-up 1044 return os::elapsedTime(); 1045 } 1046 1047 const Ticks now = Ticks::now(); 1048 const Tickspan time_since_last = now - _end_of_last; 1049 return TicksToTimeHelper::seconds(time_since_last); 1050 } 1051 1052 // 1053 // Stat load 1054 // 1055 void ZStatLoad::print() { 1056 double loadavg[3] = {}; 1057 os::loadavg(loadavg, ARRAY_SIZE(loadavg)); 1058 log_info(gc, load)("Load: %.2f/%.2f/%.2f", loadavg[0], loadavg[1], loadavg[2]); | 995 return _buffer; 996 } 997 }; 998 999 public: 1000 ZStatTablePrinter(size_t column0_width, size_t columnN_width) : 1001 _column0_width(column0_width), 1002 _columnN_width(columnN_width) {} 1003 1004 ZColumn operator()() { 1005 return ZColumn(_buffer, 0, _column0_width, _columnN_width); 1006 } 1007 }; 1008 1009 // 1010 // Stat cycle 1011 // 1012 uint64_t ZStatCycle::_ncycles = 0; 1013 Ticks ZStatCycle::_start_of_last; 1014 Ticks ZStatCycle::_end_of_last; 1015 NumberSeq ZStatCycle::_normalized_duration(0.3 /* alpha */); 1016 1017 void ZStatCycle::at_start() { 1018 _start_of_last = Ticks::now(); 1019 } 1020 1021 void ZStatCycle::at_end(double boost_factor) { 1022 _end_of_last = Ticks::now(); 1023 _ncycles++; 1024 1025 // Calculate normalized cycle duration. The measured duration is 1026 // normalized using the boost factor to avoid artificial deflation 1027 // of the duration when boost mode is enabled. 1028 const double duration = TicksToTimeHelper::seconds(_end_of_last - _start_of_last); 1029 const double normalized_duration = duration * boost_factor; 1030 _normalized_duration.add(normalized_duration); 1031 } 1032 1033 uint64_t ZStatCycle::ncycles() { 1034 return _ncycles; 1035 } 1036 1037 const AbsSeq& ZStatCycle::normalized_duration() { 1038 return _normalized_duration; 1039 } 1040 1041 double ZStatCycle::time_since_last() { 1042 if (_ncycles == 0) { 1043 // Return time since VM start-up 1044 return os::elapsedTime(); 1045 } 1046 1047 const Ticks now = Ticks::now(); 1048 const Tickspan time_since_last = now - _end_of_last; 1049 return TicksToTimeHelper::seconds(time_since_last); 1050 } 1051 1052 // 1053 // Stat load 1054 // 1055 void ZStatLoad::print() { 1056 double loadavg[3] = {}; 1057 os::loadavg(loadavg, ARRAY_SIZE(loadavg)); 1058 log_info(gc, load)("Load: %.2f/%.2f/%.2f", loadavg[0], loadavg[1], loadavg[2]); |