Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx2/src/external/bullet/LinearMath/btQuickprof.h @ 11125

Last change on this file since 11125 was 8351, checked in by rgrieder, 14 years ago

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
1
2/***************************************************************************************************
3**
4** Real-Time Hierarchical Profiling for Game Programming Gems 3
5**
6** by Greg Hjelstrom & Byon Garrabrant
7**
8***************************************************************************************************/
9
10// Credits: The Clock class was inspired by the Timer classes in
11// Ogre (www.ogre3d.org).
12
13
14
15#ifndef QUICK_PROF_H
16#define QUICK_PROF_H
17
18//To disable built-in profiling, please comment out next line
19//#define BT_NO_PROFILE 1
20#ifndef BT_NO_PROFILE
21#include <stdio.h>//@todo remove this, backwards compatibility
22#include "btScalar.h"
23#include "btAlignedAllocator.h"
24#include <new>
25
26
27
28
29
30#define USE_BT_CLOCK 1
31
32#ifdef USE_BT_CLOCK
33
34///The btClock is a portable basic clock that measures accurate time in seconds, use for profiling.
35class btClock
36{
37public:
38        btClock();
39
40        btClock(const btClock& other);
41        btClock& operator=(const btClock& other);
42
43        ~btClock();
44
45        /// Resets the initial reference time.
46        void reset();
47
48        /// Returns the time in ms since the last call to reset or since
49        /// the btClock was created.
50        unsigned long int getTimeMilliseconds();
51
52        /// Returns the time in us since the last call to reset or since
53        /// the Clock was created.
54        unsigned long int getTimeMicroseconds();
55private:
56        struct btClockData* m_data;
57};
58
59#endif //USE_BT_CLOCK
60
61
62
63
64///A node in the Profile Hierarchy Tree
65class   CProfileNode {
66
67public:
68        CProfileNode( const char * name, CProfileNode * parent );
69        ~CProfileNode( void );
70
71        CProfileNode * Get_Sub_Node( const char * name );
72
73        CProfileNode * Get_Parent( void )               { return Parent; }
74        CProfileNode * Get_Sibling( void )              { return Sibling; }
75        CProfileNode * Get_Child( void )                        { return Child; }
76
77        void                            CleanupMemory();
78        void                            Reset( void );
79        void                            Call( void );
80        bool                            Return( void );
81
82        const char *    Get_Name( void )                                { return Name; }
83        int                             Get_Total_Calls( void )         { return TotalCalls; }
84        float                           Get_Total_Time( void )          { return TotalTime; }
85
86protected:
87
88        const char *    Name;
89        int                             TotalCalls;
90        float                           TotalTime;
91        unsigned long int                       StartTime;
92        int                             RecursionCounter;
93
94        CProfileNode *  Parent;
95        CProfileNode *  Child;
96        CProfileNode *  Sibling;
97};
98
99///An iterator to navigate through the tree
100class CProfileIterator
101{
102public:
103        // Access all the children of the current parent
104        void                            First(void);
105        void                            Next(void);
106        bool                            Is_Done(void);
107        bool                Is_Root(void) { return (CurrentParent->Get_Parent() == 0); }
108
109        void                            Enter_Child( int index );               // Make the given child the new parent
110        void                            Enter_Largest_Child( void );    // Make the largest child the new parent
111        void                            Enter_Parent( void );                   // Make the current parent's parent the new parent
112
113        // Access the current child
114        const char *    Get_Current_Name( void )                        { return CurrentChild->Get_Name(); }
115        int                             Get_Current_Total_Calls( void ) { return CurrentChild->Get_Total_Calls(); }
116        float                           Get_Current_Total_Time( void )  { return CurrentChild->Get_Total_Time(); }
117
118        // Access the current parent
119        const char *    Get_Current_Parent_Name( void )                 { return CurrentParent->Get_Name(); }
120        int                             Get_Current_Parent_Total_Calls( void )  { return CurrentParent->Get_Total_Calls(); }
121        float                           Get_Current_Parent_Total_Time( void )   { return CurrentParent->Get_Total_Time(); }
122
123protected:
124
125        CProfileNode *  CurrentParent;
126        CProfileNode *  CurrentChild;
127
128        CProfileIterator( CProfileNode * start );
129        friend  class           CProfileManager;
130};
131
132
133///The Manager for the Profile system
134class   CProfileManager {
135public:
136        static  void                                            Start_Profile( const char * name );
137        static  void                                            Stop_Profile( void );
138
139        static  void                                            CleanupMemory(void)
140        {
141                Root.CleanupMemory();
142        }
143
144        static  void                                            Reset( void );
145        static  void                                            Increment_Frame_Counter( void );
146        static  int                                             Get_Frame_Count_Since_Reset( void )             { return FrameCounter; }
147        static  float                                           Get_Time_Since_Reset( void );
148
149        static  CProfileIterator *      Get_Iterator( void )   
150        { 
151               
152                return new CProfileIterator( &Root ); 
153        }
154        static  void                                            Release_Iterator( CProfileIterator * iterator ) { delete ( iterator); }
155
156        static void     dumpRecursive(CProfileIterator* profileIterator, int spacing);
157
158        static void     dumpAll();
159
160private:
161        static  CProfileNode                    Root;
162        static  CProfileNode *                  CurrentNode;
163        static  int                                             FrameCounter;
164        static  unsigned long int                                       ResetTime;
165};
166
167
168///ProfileSampleClass is a simple way to profile a function's scope
169///Use the BT_PROFILE macro at the start of scope to time
170class   CProfileSample {
171public:
172        CProfileSample( const char * name )
173        { 
174                CProfileManager::Start_Profile( name ); 
175        }
176
177        ~CProfileSample( void )                                 
178        { 
179                CProfileManager::Stop_Profile(); 
180        }
181};
182
183
184#define BT_PROFILE( name )                      CProfileSample __profile( name )
185
186#else
187
188#define BT_PROFILE( name )
189
190#endif //#ifndef BT_NO_PROFILE
191
192
193
194#endif //QUICK_PROF_H
195
196
Note: See TracBrowser for help on using the repository browser.