pstats: Show collector start count in mouse-over tooltips

This commit is contained in:
rdb 2022-11-29 18:26:51 +01:00
parent a5610f217e
commit 36aec8b014
4 changed files with 33 additions and 3 deletions

View File

@ -166,7 +166,11 @@ get_bar_tooltip(int depth, int x) const {
if (client_data != nullptr && client_data->has_collector(level->_collector_index)) {
std::ostringstream text;
text << client_data->get_collector_fullname(level->_collector_index);
text << " (" << format_number(level->get_net_value(_average_mode), GBU_show_units | GBU_ms) << ")";
text << " (" << format_number(level->get_net_value(_average_mode), GBU_show_units | GBU_ms);
if (level->_count > 1) {
text << " / " << level->_count << "x";
}
text << ")";
return text.str();
}
}
@ -399,6 +403,7 @@ void PStatFlameGraph::StackLevel::
reset() {
_start_time = 0.0;
_net_value = 0.0;
_count = 0;
_started = false;
for (auto &item : _children) {
@ -416,6 +421,7 @@ start(int collector_index, double time) {
child._parent = this;
child._collector_index = collector_index;
child._start_time = std::max(_start_time, time);
child._count++;
child._started = true;
return &child;
}
@ -529,6 +535,7 @@ locate(int depth, double time, bool average) const {
void PStatFlameGraph::StackLevel::
clear() {
_children.clear();
_count = 0;
_net_value = 0.0;
}

View File

@ -107,6 +107,7 @@ private:
double _values[_num_average_frames] = {0.0};
double _start_time = 0.0;
int _count = 0;
bool _started = false;
int _collector_index = -1;

View File

@ -332,6 +332,8 @@ get_label_tooltip(int collector_index) const {
return std::string();
}
const PStatThreadData *thread_data = _view.get_thread_data();
std::ostringstream text;
text << client_data->get_collector_fullname(collector_index);
@ -340,7 +342,6 @@ get_label_tooltip(int collector_index) const {
value = get_average_net_value();
}
else {
const PStatThreadData *thread_data = _view.get_thread_data();
int now_i, then_i;
if (!thread_data->get_elapsed_frames(then_i, now_i)) {
return text.str();
@ -385,7 +386,22 @@ get_label_tooltip(int collector_index) const {
value = net_value / net_time;
}
text << " (" << format_number(value, get_guide_bar_units(), get_guide_bar_unit_name()) << ")";
text << " (" << format_number(value, get_guide_bar_units(), get_guide_bar_unit_name());
if (collector_index != 0) {
const FrameData &frame = get_frame_data(thread_data->get_latest_frame_number());
for (const ColorData &cd : frame) {
if (cd._collector_index == collector_index) {
if (cd._count > 0) {
text << " / " << cd._count << "x";
}
break;
}
}
}
text << ")";
return text.str();
}
@ -505,6 +521,7 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional,
ColorData scaled;
scaled._collector_index = (*bi)._collector_index;
scaled._i = (*bi)._i;
scaled._count = 0;
scaled._net_value = (*bi)._net_value * weight;
result.push_back(scaled);
++bi;
@ -514,6 +531,7 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional,
ColorData combined;
combined._collector_index = (*ai)._collector_index;
combined._i = (*bi)._i;
combined._count = 0;
combined._net_value = (*ai)._net_value + (*bi)._net_value * weight;
result.push_back(combined);
++ai;
@ -532,6 +550,7 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional,
ColorData scaled;
scaled._collector_index = (*bi)._collector_index;
scaled._i = (*bi)._i;
scaled._count = 0;
scaled._net_value = (*bi)._net_value * weight;
result.push_back(scaled);
++bi;
@ -577,6 +596,7 @@ get_frame_data(int frame_number) const {
ColorData cd;
cd._collector_index = (unsigned short)child->get_collector();
cd._i = (unsigned short)i;
cd._count = child->get_count();
cd._net_value = child->get_net_value();
if (cd._net_value != 0.0) {
fdata.push_back(cd);
@ -588,6 +608,7 @@ get_frame_data(int frame_number) const {
ColorData cd;
cd._collector_index = (unsigned short)level->get_collector();
cd._i = (unsigned short)num_children;
cd._count = level->get_count();
cd._net_value = level->get_value_alone();
if (cd._net_value > 0.0) {
fdata.push_back(cd);

View File

@ -83,6 +83,7 @@ protected:
public:
unsigned short _collector_index;
unsigned short _i;
int _count;
double _net_value;
};
typedef pvector<ColorData> FrameData;