mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
pstats: Show collector start/stop pair count in time-based graphs
It can be very useful to know how often a collector was invoked in a frame, not just how long it took. This adds a number to the upper-right corner showing exactly that (but not aggregated, just for leaf collectors).
This commit is contained in:
parent
5247446500
commit
3468b95fa9
@ -15,6 +15,7 @@
|
|||||||
#include "gtkStatsMonitor.h"
|
#include "gtkStatsMonitor.h"
|
||||||
#include "pStatCollectorDef.h"
|
#include "pStatCollectorDef.h"
|
||||||
#include "numeric_types.h"
|
#include "numeric_types.h"
|
||||||
|
#include "string_utils.h"
|
||||||
|
|
||||||
static const int default_strip_chart_width = 400;
|
static const int default_strip_chart_width = 400;
|
||||||
static const int default_strip_chart_height = 100;
|
static const int default_strip_chart_height = 100;
|
||||||
@ -120,7 +121,7 @@ new_data(int thread_index, int frame_number) {
|
|||||||
if (!_pause) {
|
if (!_pause) {
|
||||||
update();
|
update();
|
||||||
|
|
||||||
std::string text = format_number(get_average_net_value(), get_guide_bar_units(), get_guide_bar_unit_name());
|
std::string text = get_total_text();
|
||||||
if (_net_value_text != text) {
|
if (_net_value_text != text) {
|
||||||
_net_value_text = text;
|
_net_value_text = text;
|
||||||
gtk_label_set_text(GTK_LABEL(_total_label), _net_value_text.c_str());
|
gtk_label_set_text(GTK_LABEL(_total_label), _net_value_text.c_str());
|
||||||
|
@ -156,6 +156,15 @@ pixel_to_height(int x) const {
|
|||||||
return _value_height * (double)(get_ysize() - x) / (double)get_ysize();
|
return _value_height * (double)(get_ysize() - x) / (double)get_ysize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if get_title_text() has never yet returned an answer, false if
|
||||||
|
* it has.
|
||||||
|
*/
|
||||||
|
INLINE bool PStatStripChart::
|
||||||
|
is_title_unknown() const {
|
||||||
|
return _title_unknown;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the indicated collector appears anywhere on the chart at
|
* Returns true if the indicated collector appears anywhere on the chart at
|
||||||
* the current time, false otherwise.
|
* the current time, false otherwise.
|
||||||
|
@ -284,12 +284,18 @@ get_title_text() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if get_title_text() has never yet returned an answer, false if
|
* Returns the text suitable for the total label above the graph.
|
||||||
* it has.
|
|
||||||
*/
|
*/
|
||||||
bool PStatStripChart::
|
std::string PStatStripChart::
|
||||||
is_title_unknown() const {
|
get_total_text() {
|
||||||
return _title_unknown;
|
std::string text = format_number(get_average_net_value(), get_guide_bar_units(), get_guide_bar_unit_name());
|
||||||
|
if (get_collector_index() != 0 && !_view.get_show_level()) {
|
||||||
|
const PStatViewLevel *level = _view.get_level(get_collector_index());
|
||||||
|
if (level != nullptr && level->get_count() > 0) {
|
||||||
|
text += " / " + format_string(level->get_count()) + "x";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,8 +68,9 @@ public:
|
|||||||
INLINE int height_to_pixel(double value) const;
|
INLINE int height_to_pixel(double value) const;
|
||||||
INLINE double pixel_to_height(int y) const;
|
INLINE double pixel_to_height(int y) const;
|
||||||
|
|
||||||
|
INLINE bool is_title_unknown() const;
|
||||||
std::string get_title_text();
|
std::string get_title_text();
|
||||||
bool is_title_unknown() const;
|
std::string get_total_text();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class ColorData {
|
class ColorData {
|
||||||
|
@ -109,6 +109,7 @@ public:
|
|||||||
bool _is_started = false;
|
bool _is_started = false;
|
||||||
bool _pushed = false;
|
bool _pushed = false;
|
||||||
bool _is_new = false;
|
bool _is_new = false;
|
||||||
|
int _count = 0;
|
||||||
double _net_time = 0.0;
|
double _net_time = 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -315,6 +316,9 @@ update_time_data(const PStatFrameData &frame_data) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
samples[collector_index].data_point(frame_data.get_time(i), is_start, &started);
|
samples[collector_index].data_point(frame_data.get_time(i), is_start, &started);
|
||||||
|
if (is_start) {
|
||||||
|
samples[collector_index]._count++;
|
||||||
|
}
|
||||||
if (!samples[collector_index]._is_new) {
|
if (!samples[collector_index]._is_new) {
|
||||||
samples[collector_index]._is_new = true;
|
samples[collector_index]._is_new = true;
|
||||||
++new_collectors;
|
++new_collectors;
|
||||||
@ -354,6 +358,7 @@ update_time_data(const PStatFrameData &frame_data) {
|
|||||||
int collector_index = level->_collector;
|
int collector_index = level->_collector;
|
||||||
if (samples[collector_index]._is_new) {
|
if (samples[collector_index]._is_new) {
|
||||||
level->_value_alone = samples[collector_index]._net_time;
|
level->_value_alone = samples[collector_index]._net_time;
|
||||||
|
level->_count = samples[collector_index]._count;
|
||||||
samples[collector_index]._is_new = false;
|
samples[collector_index]._is_new = false;
|
||||||
--new_collectors;
|
--new_collectors;
|
||||||
}
|
}
|
||||||
@ -370,6 +375,7 @@ update_time_data(const PStatFrameData &frame_data) {
|
|||||||
if (samples[collector_index]._is_new) {
|
if (samples[collector_index]._is_new) {
|
||||||
PStatViewLevel *level = get_level(collector_index);
|
PStatViewLevel *level = get_level(collector_index);
|
||||||
level->_value_alone = samples[collector_index]._net_time;
|
level->_value_alone = samples[collector_index]._net_time;
|
||||||
|
level->_count = samples[collector_index]._count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,6 +510,7 @@ bool PStatView::
|
|||||||
reset_level(PStatViewLevel *level) {
|
reset_level(PStatViewLevel *level) {
|
||||||
bool any_changed = false;
|
bool any_changed = false;
|
||||||
level->_value_alone = 0.0;
|
level->_value_alone = 0.0;
|
||||||
|
level->_count = 0;
|
||||||
|
|
||||||
if (level->_collector == _constraint) {
|
if (level->_collector == _constraint) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,3 +27,11 @@ INLINE double PStatViewLevel::
|
|||||||
get_value_alone() const {
|
get_value_alone() const {
|
||||||
return _value_alone;
|
return _value_alone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of start/stop pairs for this collector.
|
||||||
|
*/
|
||||||
|
INLINE int PStatViewLevel::
|
||||||
|
get_count() const {
|
||||||
|
return _count;
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
INLINE int get_collector() const;
|
INLINE int get_collector() const;
|
||||||
INLINE double get_value_alone() const;
|
INLINE double get_value_alone() const;
|
||||||
double get_net_value() const;
|
double get_net_value() const;
|
||||||
|
INLINE int get_count() const;
|
||||||
|
|
||||||
void sort_children(const PStatClientData *client_data);
|
void sort_children(const PStatClientData *client_data);
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int _collector;
|
int _collector;
|
||||||
|
int _count = 0;
|
||||||
double _value_alone;
|
double _value_alone;
|
||||||
PStatViewLevel *_parent;
|
PStatViewLevel *_parent;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ new_data(int thread_index, int frame_number) {
|
|||||||
if (!_pause) {
|
if (!_pause) {
|
||||||
update();
|
update();
|
||||||
|
|
||||||
string text = format_number(get_average_net_value(), get_guide_bar_units(), get_guide_bar_unit_name());
|
std::string text = get_total_text();
|
||||||
if (_net_value_text != text) {
|
if (_net_value_text != text) {
|
||||||
_net_value_text = text;
|
_net_value_text = text;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user