41 void data_point(
double time,
bool is_start, Started &started) {
55 nassertv(is_start != _is_started);
57 _is_started = is_start;
60 nassertv(!_is_started);
61 Started::iterator si = find(started.begin(), started.end(),
this);
62 nassertv(si != started.end());
68 push_all(time, started);
69 started.push_back(
this);
72 Started::iterator si = find(started.begin(), started.end(),
this);
73 nassertv(si != started.end());
75 pop_one(time, started);
79 void push(
double time) {
87 void pop(
double time) {
96 void push_all(
double time, Started &started) {
98 for (si = started.begin(); si != started.end(); ++si) {
103 void pop_one(
double time, Started &started) {
104 Started::reverse_iterator si;
105 for (si = started.rbegin(); si != started.rend(); ++si) {
106 if ((*si)->_pushed) {
128 _all_collectors_known =
false;
158 _constraint = collector;
159 _show_level = show_level;
177 _thread_data = thread_data;
180 _all_collectors_known =
false;
195 nassertv(!_thread_data.is_null());
196 nassertv(!_client_data.is_null());
199 update_level_data(frame_data);
201 update_time_data(frame_data);
213 return _all_collectors_known;
224 Levels::const_iterator li;
225 for (li = _levels.begin(); li != _levels.end(); ++li) {
226 net += (*li).second->_value_alone;
249 Levels::const_iterator li;
250 li = _levels.find(collector);
251 return (li != _levels.end());
261 Levels::const_iterator li;
262 li = _levels.find(collector);
263 if (li != _levels.end()) {
268 level->_collector = collector;
269 level->_parent =
nullptr;
270 _levels[collector] = level;
284 Samples samples(_client_data->get_num_collectors());
288 _all_collectors_known =
true;
293 GotSamples got_samples;
296 for (i = 0; i < num_events; i++) {
298 bool is_start = frame_data.
is_start(i);
300 if (!_client_data->has_collector(collector_index)) {
301 _all_collectors_known =
false;
304 nassertv(collector_index >= 0 && collector_index < (
int)samples.size());
306 if (_client_data->get_child_distance(_constraint, collector_index) >= 0) {
309 if (is_start == samples[collector_index]._is_started) {
313 samples[collector_index].data_point(frame_data.
get_time(0),
true, started);
314 samples[collector_index].data_point(frame_data.
get_time(i), is_start, started);
318 nout <<
"Unexpected data point for " 319 << _client_data->get_collector_fullname(collector_index)
323 samples[collector_index].data_point(frame_data.
get_time(i), is_start, started);
324 got_samples.insert(collector_index);
332 Samples::iterator si;
333 for (i = 0, si = samples.begin(); si != samples.end(); ++i, ++si) {
334 if ((*si)._is_started) {
335 (*si).data_point(frame_data.
get_end(),
false, started);
339 nassertv(started.empty());
341 bool any_new_levels =
false;
345 Levels::iterator li, lnext;
346 li = _levels.begin();
347 while (li != _levels.end()) {
354 if (reset_level(level)) {
355 any_new_levels =
true;
358 int collector_index = level->_collector;
359 GotSamples::iterator gi;
360 gi = got_samples.find(collector_index);
361 if (gi != got_samples.end()) {
362 level->_value_alone = samples[collector_index]._net_time;
363 got_samples.erase(gi);
371 if (!got_samples.empty()) {
372 any_new_levels =
true;
374 GotSamples::const_iterator gi;
375 for (gi = got_samples.begin(); gi != got_samples.end(); ++gi) {
376 int collector_index = (*gi);
378 level->_value_alone = samples[*gi]._net_time;
382 if (any_new_levels) {
392 _all_collectors_known =
true;
397 GotValues net_values;
401 for (i = 0; i < num_levels; i++) {
405 if (!_client_data->has_collector(collector_index)) {
406 _all_collectors_known =
false;
409 if (_client_data->get_child_distance(_constraint, collector_index) >= 0) {
410 net_values[collector_index] = value;
418 GotValues alone_values = net_values;
420 GotValues::iterator gi;
421 for (gi = net_values.begin(); gi != net_values.end(); ++gi) {
422 int collector_index = (*gi).first;
423 double value = (*gi).second;
426 while (collector_index != 0 && collector_index != _constraint) {
428 _client_data->get_collector_def(collector_index);
429 int parent_index = def._parent_index;
430 GotValues::iterator pi = alone_values.find(parent_index);
431 if (pi != alone_values.end()) {
433 (*pi).second -= value;
436 collector_index = parent_index;
441 bool any_new_levels =
false;
445 Levels::iterator li, lnext;
446 li = _levels.begin();
447 while (li != _levels.end()) {
454 if (reset_level(level)) {
455 any_new_levels =
true;
458 int collector_index = level->_collector;
459 GotValues::iterator gi;
460 gi = alone_values.find(collector_index);
461 if (gi != alone_values.end()) {
462 level->_value_alone = (*gi).second;
463 alone_values.erase(gi);
471 if (!alone_values.empty()) {
472 any_new_levels =
true;
474 GotValues::const_iterator gi;
475 for (gi = alone_values.begin(); gi != alone_values.end(); ++gi) {
476 int collector_index = (*gi).first;
478 level->_value_alone = (*gi).second;
482 if (any_new_levels) {
493 for (li = _levels.begin(); li != _levels.end(); ++li) {
510 bool any_changed =
false;
511 level->_value_alone = 0.0;
513 if (level->_collector == _constraint) {
517 if (_client_data->has_collector(level->_collector)) {
519 _client_data->get_collector_def(level->_collector)._parent_index;
521 if (level->_parent ==
nullptr) {
524 nassertr(parent_level != level,
true);
526 level->_parent = parent_level;
527 parent_level->_children.push_back(level);
531 }
else if (level->_parent->_collector != parent_index) {
534 nassertr(old_parent_level != level,
true);
536 if (parent_index != 0) {
538 nassertr(new_parent_level != level,
true);
539 level->_parent = new_parent_level;
540 new_parent_level->_children.push_back(level);
543 level->_parent =
nullptr;
546 PStatViewLevel::Children::iterator ci =
547 find(old_parent_level->_children.begin(),
548 old_parent_level->_children.end(),
551 nassertr(ci != old_parent_level->_children.end(),
true);
552 old_parent_level->_children.erase(ci);
const PStatViewLevel * get_top_level()
Returns a pointer to the level that corresponds to the Collector we've constrained to.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void sort_children(const PStatClientData *client_data)
Sorts the children of this view level into order as specified by the client's sort index.
This is our own Panda specialization on the default STL map.
void set_to_frame(const PStatFrameData &frame_data)
Supplies the View with the data for the current frame.
int get_level_collector(size_t n) const
Returns the index of the collector associated with the nth level value.
void unconstrain()
Restores the view to the full frame.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL list.
double get_level(size_t n) const
Returns the height of the nth level value.
double get_net_value() const
Returns the total value accounted for by the frame (or by whatever Collector we are constrained to).
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
This is a single level value, or band of color, within a View.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Contains the raw timing and level data for a single frame.
double get_time(size_t n) const
Returns the timestamp of the nth event, in seconds elapsed since some undefined epoch (which is guara...
bool all_collectors_known() const
After a call to set_to_frame(), this returns true if all collectors in the FrameData are known by the...
size_t get_num_levels() const
Returns the number of individual level values stored in the FrameData.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A collection of FrameData structures for recently-received frames within a particular thread.
int get_time_collector(size_t n) const
Returns the index of the collector associated with the nth event.
bool is_start(size_t n) const
Returns true if the nth event represents a start event, or false if it represents a stop event.
void constrain(int collector, bool show_level)
Changes the focus of the View.
double get_end() const
Returns the time of the last data point in the frame data.
size_t get_num_events() const
Returns the number of individual events stored in the FrameData.
Defines the details about the Collectors: the name, the suggested color, etc.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool has_level(int collector) const
Returns true if there is a level defined for the particular collector, false otherwise.
PStatViewLevel * get_level(int collector)
Returns a pointer to the level that corresponds to the indicated Collector.
const PStatClientData * get_client_data() const
Returns a pointer to the ClientData structure associated with this data.