This commit is contained in:
David Rose 2007-07-13 18:55:20 +00:00
parent adf6c06b0f
commit b68f94fed7
6 changed files with 65 additions and 3 deletions

View File

@ -13,7 +13,8 @@
interrogatedb:c dtoolutil:c dtoolbase:c prc:c dconfig:c dtoolconfig:m dtool:m pystub
#define SOURCES \
textMonitor.cxx textMonitor.h textStats.cxx textStats.h
textMonitor.cxx textMonitor.h textMonitor.I \
textStats.cxx textStats.h
#define INSTALL_HEADERS

View File

@ -0,0 +1,18 @@
// Filename: textMonitor.I
// Created by: drose (13Jul07)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////

View File

@ -19,8 +19,9 @@
#include "textMonitor.h"
#include "textStats.h"
#include "pStatCollectorDef.h"
#include "pStatFrameData.h"
#include "indent.h"
#include <stdio.h> // sprintf
////////////////////////////////////////////////////////////////////
// Function: TextMonitor::Constructor
@ -31,6 +32,16 @@ TextMonitor::
TextMonitor(TextStats *server) : PStatMonitor(server) {
}
////////////////////////////////////////////////////////////////////
// Function: TextMonitor::get_server
// Access: Public
// Description: Returns the server that owns this monitor.
////////////////////////////////////////////////////////////////////
TextStats *TextMonitor::
get_server() {
return (TextStats *)PStatMonitor::get_server();
}
////////////////////////////////////////////////////////////////////
// Function: TextMonitor::get_monitor_name
// Access: Public, Virtual
@ -103,6 +114,28 @@ new_data(int thread_index, int frame_number) {
<< " frame " << frame_number << ", "
<< view.get_net_value() * 1000.0 << " ms ("
<< thread_data->get_frame_rate() << " Hz):\n";
if (get_server()->_show_raw_data) {
const PStatFrameData &frame_data = thread_data->get_frame(frame_number);
nout << "raw data:\n";
int num_events = frame_data.get_num_events();
for (int i = 0; i < num_events; ++i) {
// The iomanipulators are much too clumsy.
char formatted[32];
sprintf(formatted, "%15.06lf", frame_data.get_time(i));
nout << formatted;
if (frame_data.is_start(i)) {
nout << " start ";
} else {
nout << " stop ";
}
int collector_index = frame_data.get_time_collector(i);
nout << client_data->get_collector_fullname(collector_index) << "\n";
}
}
const PStatViewLevel *level = view.get_top_level();
int num_children = level->get_num_children();
for (int i = 0; i < num_children; i++) {

View File

@ -32,6 +32,7 @@ class TextStats;
class TextMonitor : public PStatMonitor {
public:
TextMonitor(TextStats *server);
TextStats *get_server();
virtual string get_monitor_name();
@ -46,4 +47,6 @@ public:
void show_level(const PStatViewLevel *level, int indent_level);
};
#include "textMonitor.I"
#endif

View File

@ -51,6 +51,12 @@ TextStats() {
"is taken from the pstats-host Config variable.",
&TextStats::dispatch_int, NULL, &_port);
add_option
("r", "", 0,
"Show the raw frame data, in addition to boiling it down to a total "
"time per collector.",
&TextStats::dispatch_none, &_show_raw_data, NULL);
_port = pstats_port;
}

View File

@ -38,6 +38,7 @@ public:
void run();
int _port;
bool _show_raw_data;
};
#endif