29 void start(
double time, FrameSample *started) {
37 push_all(time, started);
38 nassertv(_next ==
nullptr && _prev ==
nullptr);
39 _prev = started->_prev;
42 started->_prev =
this;
45 void stop(
double time, FrameSample *started) {
46 nassertv(_started > 0);
51 nassertv(_next !=
nullptr && _prev !=
nullptr);
56 _next = _prev =
nullptr;
61 _next = _prev =
nullptr;
62 pop_one(time, started);
67 void push(
double time) {
76 void pop(
double time) {
85 void push_all(
double time, FrameSample *started) {
86 for (FrameSample *sample = started->_next;
87 sample != started; sample = sample->_next) {
92 void pop_one(
double time, FrameSample *started) {
93 for (FrameSample *sample = started->_prev;
94 sample != started; sample = sample->_prev) {
95 if (sample->_pushed) {
103 FrameSample *_next =
nullptr;
104 FrameSample *_prev =
nullptr;
105 double _net_time = 0.0;
108 bool _pushed =
false;
109 bool _is_new =
false;
119 _all_collectors_known =
false;
148constrain(
int collector,
bool show_level) {
149 _constraint = collector;
150 _show_level = show_level;
168 _thread_data = thread_data;
171 _all_collectors_known =
false;
186 nassertv(!_thread_data.is_null());
187 nassertv(!_client_data.is_null());
190 update_level_data(frame_data);
192 update_time_data(frame_data);
204 return _all_collectors_known;
215 Levels::const_iterator li;
216 for (li = _levels.begin(); li != _levels.end(); ++li) {
217 net += (*li).second->_value_alone;
240 Levels::const_iterator li;
241 li = _levels.find(collector);
242 return (li != _levels.end());
252 Levels::const_iterator li;
253 li = _levels.find(collector);
254 if (li != _levels.end()) {
259 level->_collector = collector;
260 level->_parent =
nullptr;
261 _levels[collector] = level;
273 int num_collectors = _client_data->get_num_collectors();
275 typedef std::vector<FrameSample> Samples;
276 Samples samples(num_collectors);
280 started._next = &started;
281 started._prev = &started;
283 _all_collectors_known =
true;
285 int new_collectors = 0;
287 for (i = 0; i < num_events; i++) {
289 bool is_start = frame_data.
is_start(i);
291 if (!_client_data->has_collector(collector_index)) {
292 _all_collectors_known =
false;
295 nassertv(collector_index >= 0 && collector_index < num_collectors);
297 if (_client_data->get_child_distance(_constraint, collector_index) >= 0) {
301 samples[collector_index].start(frame_data.
get_time(i), &started);
302 samples[collector_index]._count++;
306 if (samples[collector_index]._started == 0) {
307 samples[collector_index].start(frame_data.
get_time(0), &started);
309 samples[collector_index].stop(frame_data.
get_time(i), &started);
312 if (!samples[collector_index]._is_new) {
313 samples[collector_index]._is_new =
true;
321 Samples::iterator si;
322 for (i = 0, si = samples.begin(); si != samples.end(); ++i, ++si) {
323 if ((*si)._started > 0) {
324 (*si).stop(frame_data.
get_end(), &started);
328 nassertv(started._next == &started && started._prev == &started);
330 bool any_new_levels =
false;
334 Levels::iterator li, lnext;
335 li = _levels.begin();
336 while (li != _levels.end()) {
343 if (reset_level(level)) {
344 any_new_levels =
true;
347 int collector_index = level->_collector;
348 if (samples[collector_index]._is_new) {
349 level->_value_alone = samples[collector_index]._net_time;
350 level->_count = samples[collector_index]._count;
351 samples[collector_index]._is_new =
false;
360 if (new_collectors > 0) {
361 any_new_levels =
true;
363 for (
int collector_index = 0; collector_index < num_collectors; ++collector_index) {
364 if (samples[collector_index]._is_new) {
366 level->_value_alone = samples[collector_index]._net_time;
367 level->_count = samples[collector_index]._count;
372 if (any_new_levels) {
382 _all_collectors_known =
true;
387 GotValues net_values;
391 for (i = 0; i < num_levels; i++) {
395 if (!_client_data->has_collector(collector_index)) {
396 _all_collectors_known =
false;
399 if (_client_data->get_child_distance(_constraint, collector_index) >= 0) {
400 net_values[collector_index] = value;
408 GotValues alone_values = net_values;
410 GotValues::iterator gi;
411 for (gi = net_values.begin(); gi != net_values.end(); ++gi) {
412 int collector_index = (*gi).first;
413 double value = (*gi).second;
416 while (collector_index != 0 && collector_index != _constraint) {
418 _client_data->get_collector_def(collector_index);
419 int parent_index = def._parent_index;
420 GotValues::iterator pi = alone_values.find(parent_index);
421 if (pi != alone_values.end()) {
423 (*pi).second -= value;
426 collector_index = parent_index;
431 bool any_new_levels =
false;
435 Levels::iterator li, lnext;
436 li = _levels.begin();
437 while (li != _levels.end()) {
444 if (reset_level(level)) {
445 any_new_levels =
true;
448 int collector_index = level->_collector;
449 GotValues::iterator gi;
450 gi = alone_values.find(collector_index);
451 if (gi != alone_values.end()) {
452 level->_value_alone = (*gi).second;
453 alone_values.erase(gi);
461 if (!alone_values.empty()) {
462 any_new_levels =
true;
464 GotValues::const_iterator gi;
465 for (gi = alone_values.begin(); gi != alone_values.end(); ++gi) {
466 int collector_index = (*gi).first;
468 level->_value_alone = (*gi).second;
472 if (any_new_levels) {
483 for (li = _levels.begin(); li != _levels.end(); ++li) {
500 bool any_changed =
false;
501 level->_value_alone = 0.0;
504 if (level->_collector == _constraint) {
508 if (_client_data->has_collector(level->_collector)) {
510 _client_data->get_collector_def(level->_collector)._parent_index;
512 if (level->_parent ==
nullptr) {
515 nassertr(parent_level != level,
true);
517 level->_parent = parent_level;
518 parent_level->_children.push_back(level);
522 }
else if (level->_parent->_collector != parent_index) {
525 nassertr(old_parent_level != level,
true);
527 if (parent_index != 0) {
529 nassertr(new_parent_level != level,
true);
530 level->_parent = new_parent_level;
531 new_parent_level->_children.push_back(level);
534 level->_parent =
nullptr;
537 PStatViewLevel::Children::iterator ci =
538 find(old_parent_level->_children.begin(),
539 old_parent_level->_children.end(),
542 nassertr(ci != old_parent_level->_children.end(),
true);
543 old_parent_level->_children.erase(ci);
Defines the details about the Collectors: the name, the suggested color, etc.
Contains the raw timing and level data for a single frame.
double get_end() const
Returns the time of the last data point in the frame data.
double get_time(size_t n) const
Returns the timestamp of the nth event, in seconds elapsed since some undefined epoch (which is guara...
int get_time_collector(size_t n) const
Returns the index of the collector associated with the nth event.
size_t get_num_levels() const
Returns the number of individual level values stored in the FrameData.
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.
size_t get_num_events() const
Returns the number of individual events stored in the FrameData.
double get_level(size_t n) const
Returns the height of the nth level value.
int get_level_collector(size_t n) const
Returns the index of the collector associated with the nth level value.
A collection of FrameData structures for recently-received frames within a particular thread.
const PStatClientData * get_client_data() const
Returns a pointer to the ClientData structure associated with this data.
This is a single level value, or band of color, within a View.
void sort_children(const PStatClientData *client_data)
Sorts the children of this view level into order as specified by the client's sort index.
double get_net_value() const
Returns the total value accounted for by the frame (or by whatever Collector we are constrained to).
const PStatViewLevel * get_top_level()
Returns a pointer to the level that corresponds to the Collector we've constrained to.
void set_to_frame(const PStatFrameData &frame_data)
Supplies the View with the data for the current frame.
void unconstrain()
Restores the view to the full frame.
void constrain(int collector, bool show_level)
Changes the focus of the View.
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...
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.
This is our own Panda specialization on the default STL map.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.