From b68f94fed7dc42afb11bc6311e1045f6130105af Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 13 Jul 2007 18:55:20 +0000 Subject: [PATCH] add -r --- pandatool/src/text-stats/Sources.pp | 3 +- pandatool/src/text-stats/textMonitor.I | 18 ++++++++++++ pandatool/src/text-stats/textMonitor.cxx | 35 +++++++++++++++++++++++- pandatool/src/text-stats/textMonitor.h | 5 +++- pandatool/src/text-stats/textStats.cxx | 6 ++++ pandatool/src/text-stats/textStats.h | 1 + 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100755 pandatool/src/text-stats/textMonitor.I diff --git a/pandatool/src/text-stats/Sources.pp b/pandatool/src/text-stats/Sources.pp index 7f9f79080a..f25bb4527e 100644 --- a/pandatool/src/text-stats/Sources.pp +++ b/pandatool/src/text-stats/Sources.pp @@ -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 diff --git a/pandatool/src/text-stats/textMonitor.I b/pandatool/src/text-stats/textMonitor.I new file mode 100755 index 0000000000..f40324db86 --- /dev/null +++ b/pandatool/src/text-stats/textMonitor.I @@ -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 . +// +//////////////////////////////////////////////////////////////////// + diff --git a/pandatool/src/text-stats/textMonitor.cxx b/pandatool/src/text-stats/textMonitor.cxx index e06c609a2d..52535306ee 100644 --- a/pandatool/src/text-stats/textMonitor.cxx +++ b/pandatool/src/text-stats/textMonitor.cxx @@ -19,8 +19,9 @@ #include "textMonitor.h" #include "textStats.h" #include "pStatCollectorDef.h" - +#include "pStatFrameData.h" #include "indent.h" +#include // 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++) { diff --git a/pandatool/src/text-stats/textMonitor.h b/pandatool/src/text-stats/textMonitor.h index a242f357b4..951204c3cf 100644 --- a/pandatool/src/text-stats/textMonitor.h +++ b/pandatool/src/text-stats/textMonitor.h @@ -32,7 +32,8 @@ class TextStats; class TextMonitor : public PStatMonitor { public: TextMonitor(TextStats *server); - + TextStats *get_server(); + virtual string get_monitor_name(); virtual void got_hello(); @@ -46,4 +47,6 @@ public: void show_level(const PStatViewLevel *level, int indent_level); }; +#include "textMonitor.I" + #endif diff --git a/pandatool/src/text-stats/textStats.cxx b/pandatool/src/text-stats/textStats.cxx index 12ab444264..eea424b14e 100644 --- a/pandatool/src/text-stats/textStats.cxx +++ b/pandatool/src/text-stats/textStats.cxx @@ -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; } diff --git a/pandatool/src/text-stats/textStats.h b/pandatool/src/text-stats/textStats.h index 0f93ef46a2..0806fffc5b 100644 --- a/pandatool/src/text-stats/textStats.h +++ b/pandatool/src/text-stats/textStats.h @@ -38,6 +38,7 @@ public: void run(); int _port; + bool _show_raw_data; }; #endif