diff --git a/direct/src/dcparser/Sources.pp b/direct/src/dcparser/Sources.pp index 9b14c1e4de..f8aec3a075 100644 --- a/direct/src/dcparser/Sources.pp +++ b/direct/src/dcparser/Sources.pp @@ -1,5 +1,6 @@ #define OTHER_LIBS \ express:c pandaexpress:m \ + pstatclient:c panda:m \ interrogatedb:c dconfig:c dtoolconfig:m \ dtoolutil:c dtoolbase:c dtool:m #define LOCAL_LIBS \ @@ -15,7 +16,7 @@ #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx #define SOURCES \ - dcAtomicField.h dcClass.h \ + dcAtomicField.h dcClass.h dcClass.I \ dcDeclaration.h \ dcField.h dcFile.h dcLexer.lxx \ dcLexerDefs.h dcMolecularField.h dcParser.yxx dcParserDefs.h \ diff --git a/direct/src/dcparser/dcClass.I b/direct/src/dcparser/dcClass.I new file mode 100644 index 0000000000..081ecc84e9 --- /dev/null +++ b/direct/src/dcparser/dcClass.I @@ -0,0 +1,76 @@ +// Filename: dcClass.I +// Created by: drose (15Sep04) +// +//////////////////////////////////////////////////////////////////// +// +// 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 . +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: DCClass::is_struct +// Access: Public +// Description: Returns true if the class has been identified with +// the "struct" keyword in the dc file, false if it was +// declared with "dclass". +//////////////////////////////////////////////////////////////////// +INLINE bool DCClass:: +is_struct() const { + return _is_struct; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCClass::is_bogus_class +// Access: Public +// Description: Returns true if the class has been flagged as a bogus +// class. This is set for classes that are generated by +// the parser as placeholder for missing classes, as +// when reading a partial file; it should not occur in a +// normal valid dc file. +//////////////////////////////////////////////////////////////////// +INLINE bool DCClass:: +is_bogus_class() const { + return _bogus_class; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCClass::start_generate +// Access: Public +// Description: Starts the PStats timer going on the "generate" task, +// that is, marks the beginning of the process of +// generating a new object, for the purposes of timing +// this process. +// +// This should balance with a corresponding call to +// stop_generate(). +//////////////////////////////////////////////////////////////////// +INLINE void DCClass:: +start_generate() { +#ifdef WITHIN_PANDA + _class_generate_pcollector.start(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: DCClass::stop_generate +// Access: Public +// Description: Stops the PStats timer on the "generate" task. +// This should balance with a preceding call to +// start_generate(). +//////////////////////////////////////////////////////////////////// +INLINE void DCClass:: +stop_generate() { +#ifdef WITHIN_PANDA + _class_generate_pcollector.stop(); +#endif +} diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index fff46f385d..10d0bc66ce 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -24,6 +24,15 @@ #include "dcClassParameter.h" +#ifdef WITHIN_PANDA +#include "pStatTimer.h" + +#ifndef CPPPARSER +PStatCollector DCClass::_update_pcollector("App:Show code:readerPollTask:Update"); +PStatCollector DCClass::_generate_pcollector("App:Show code:readerPollTask:Generate"); +#endif // CPPPARSER +#endif // WITHIN_PANDA + //////////////////////////////////////////////////////////////////// // Function: DCClass::Constructor // Access: Public @@ -31,6 +40,10 @@ //////////////////////////////////////////////////////////////////// DCClass:: DCClass(const string &name, bool is_struct, bool bogus_class) : +#ifdef WITHIN_PANDA + _class_update_pcollector(_update_pcollector, name), + _class_generate_pcollector(_generate_pcollector, name), +#endif _name(name), _is_struct(is_struct), _bogus_class(bogus_class) @@ -247,32 +260,6 @@ get_inherited_field(int n) const { return get_field(n); } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::is_struct -// Access: Public -// Description: Returns true if the class has been identified with -// the "struct" keyword in the dc file, false if it was -// declared with "dclass". -//////////////////////////////////////////////////////////////////// -bool DCClass:: -is_struct() const { - return _is_struct; -} - -//////////////////////////////////////////////////////////////////// -// Function: DCClass::is_bogus_class -// Access: Public -// Description: Returns true if the class has been flagged as a bogus -// class. This is set for classes that are generated by -// the parser as placeholder for missing classes, as -// when reading a partial file; it should not occur in a -// normal valid dc file. -//////////////////////////////////////////////////////////////////// -bool DCClass:: -is_bogus_class() const { - return _bogus_class; -} - #ifdef HAVE_PYTHON //////////////////////////////////////////////////////////////////// // Function: DCClass::has_class_def @@ -331,6 +318,9 @@ get_class_def() const { //////////////////////////////////////////////////////////////////// void DCClass:: receive_update(PyObject *distobj, DatagramIterator &di) const { +#ifdef WITHIN_PANDA + PStatTimer timer(((DCClass *)this)->_class_update_pcollector); +#endif DCPacker packer; packer.set_unpack_data(di.get_remaining_bytes()); @@ -356,6 +346,9 @@ receive_update(PyObject *distobj, DatagramIterator &di) const { //////////////////////////////////////////////////////////////////// void DCClass:: receive_update_broadcast_required(PyObject *distobj, DatagramIterator &di) const { +#ifdef WITHIN_PANDA + PStatTimer timer(((DCClass *)this)->_class_update_pcollector); +#endif DCPacker packer; packer.set_unpack_data(di.get_remaining_bytes()); @@ -388,6 +381,9 @@ receive_update_broadcast_required(PyObject *distobj, DatagramIterator &di) const //////////////////////////////////////////////////////////////////// void DCClass:: receive_update_all_required(PyObject *distobj, DatagramIterator &di) const { +#ifdef WITHIN_PANDA + PStatTimer timer(((DCClass *)this)->_class_update_pcollector); +#endif DCPacker packer; packer.set_unpack_data(di.get_remaining_bytes()); @@ -417,6 +413,9 @@ receive_update_all_required(PyObject *distobj, DatagramIterator &di) const { //////////////////////////////////////////////////////////////////// void DCClass:: receive_update_other(PyObject *distobj, DatagramIterator &di) const { +#ifdef WITHIN_PANDA + PStatTimer timer(((DCClass *)this)->_class_update_pcollector); +#endif int num_fields = di.get_uint16(); for (int i = 0; i < num_fields && !PyErr_Occurred(); i++) { receive_update(distobj, di); diff --git a/direct/src/dcparser/dcClass.h b/direct/src/dcparser/dcClass.h index fcef1870e7..49a60ed0f5 100644 --- a/direct/src/dcparser/dcClass.h +++ b/direct/src/dcparser/dcClass.h @@ -24,6 +24,10 @@ #include "dcDeclaration.h" #include "dcPython.h" +#ifdef WITHIN_PANDA +#include "pStatCollector.h" +#endif + class HashGenerator; class DCParameter; @@ -57,8 +61,11 @@ PUBLISHED: int get_num_inherited_fields() const; DCField *get_inherited_field(int n) const; - bool is_struct() const; - bool is_bogus_class() const; + INLINE bool is_struct() const; + INLINE bool is_bogus_class() const; + + INLINE void start_generate(); + INLINE void stop_generate(); #ifdef HAVE_PYTHON bool has_class_def() const; @@ -101,6 +108,13 @@ public: void set_number(int number); private: +#ifdef WITHIN_PANDA + PStatCollector _class_update_pcollector; + PStatCollector _class_generate_pcollector; + static PStatCollector _update_pcollector; + static PStatCollector _generate_pcollector; +#endif + string _name; bool _is_struct; bool _bogus_class; @@ -122,4 +136,6 @@ private: #endif }; +#include "dcClass.I" + #endif diff --git a/direct/src/distributed/ClientRepository.py b/direct/src/distributed/ClientRepository.py index e95c00bdde..3d6a5c7d3c 100644 --- a/direct/src/distributed/ClientRepository.py +++ b/direct/src/distributed/ClientRepository.py @@ -101,8 +101,10 @@ class ClientRepository(ConnectionRepository.ConnectionRepository): doId = di.getUint32() # Look up the dclass dclass = self.dclassesByNumber[classId] + dclass.startGenerate() # Create a new distributed object, and put it in the dictionary distObj = self.generateWithRequiredFields(dclass, doId, di) + dclass.stopGenerate() def handleGenerateWithRequiredOther(self, di): # Get the class Id @@ -111,8 +113,10 @@ class ClientRepository(ConnectionRepository.ConnectionRepository): doId = di.getUint32() # Look up the dclass dclass = self.dclassesByNumber[classId] + dclass.startGenerate() # Create a new distributed object, and put it in the dictionary distObj = self.generateWithRequiredOtherFields(dclass, doId, di) + dclass.stopGenerate() def handleQuietZoneGenerateWithRequired(self, di): # Special handler for quiet zone generates -- we need to filter @@ -122,11 +126,13 @@ class ClientRepository(ConnectionRepository.ConnectionRepository): doId = di.getUint32() # Look up the dclass dclass = self.dclassesByNumber[classId] + dclass.startGenerate() # If the class is a neverDisable class (which implies uberzone) we # should go ahead and generate it even though we are in the quiet zone if dclass.getClassDef().neverDisable: # Create a new distributed object, and put it in the dictionary distObj = self.generateWithRequiredFields(dclass, doId, di) + dclass.stopGenerate() def handleQuietZoneGenerateWithRequiredOther(self, di): # Special handler for quiet zone generates -- we need to filter @@ -138,9 +144,11 @@ class ClientRepository(ConnectionRepository.ConnectionRepository): dclass = self.dclassesByNumber[classId] # If the class is a neverDisable class (which implies uberzone) we # should go ahead and generate it even though we are in the quiet zone + dclass.startGenerate() if dclass.getClassDef().neverDisable: # Create a new distributed object, and put it in the dictionary distObj = self.generateWithRequiredOtherFields(dclass, doId, di) + dclass.stopGenerate() def generateWithRequiredFields(self, dclass, doId, di): if self.doId2do.has_key(doId): @@ -410,10 +418,12 @@ class ClientRepository(ConnectionRepository.ConnectionRepository): # watch for setZoneDones if msgType == CLIENT_DONE_SET_ZONE_RESP: self.handleSetZoneDone() + if self.handler == None: self.handleUnexpectedMsgType(msgType, di) else: self.handler(msgType, di) + # If we're processing a lot of datagrams within one frame, we # may forget to send heartbeats. Keep them coming! self.considerHeartbeat() diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index df2ba51190..1db69bbdff 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -25,9 +25,15 @@ #include "urlSpec.h" #include "datagramIterator.h" #include "throw_event.h" +#include "pStatTimer.h" + const string CConnectionRepository::_overflow_event_name = "CRDatagramOverflow"; +#ifndef CPPPARSER +PStatCollector CConnectionRepository::_update_pcollector("App:Show code:readerPollTask:Update"); +#endif // CPPPARSER + //////////////////////////////////////////////////////////////////// // Function: CConnectionRepository::Constructor // Access: Published @@ -379,6 +385,7 @@ do_check_datagram() { bool CConnectionRepository:: handle_update_field() { #ifdef HAVE_PYTHON + PStatTimer timer(_update_pcollector); int do_id = _di.get_uint32(); if (_python_repository != (PyObject *)NULL) { PyObject *doId2do = diff --git a/direct/src/distributed/cConnectionRepository.h b/direct/src/distributed/cConnectionRepository.h index fba283cbc2..7c63d593b8 100644 --- a/direct/src/distributed/cConnectionRepository.h +++ b/direct/src/distributed/cConnectionRepository.h @@ -25,6 +25,7 @@ #include "dcbase.h" #include "dcFile.h" #include "dcField.h" // to pick up Python.h +#include "pStatCollector.h" #ifdef HAVE_NSPR #include "queuedConnectionManager.h" @@ -130,6 +131,8 @@ private: unsigned int _msg_type; static const string _overflow_event_name; + + static PStatCollector _update_pcollector; }; #include "cConnectionRepository.I"