camprofile.h

Go to the documentation of this file.
00001 // $Id: camprofile.h 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 #ifndef INC_CAMPROFILE
00100 #define INC_CAMPROFILE
00101 
00102 //#include "ccobject.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00103 
00104 typedef enum
00105 {
00106     CAMPROFILE_OTHER = 0,
00107     CAMPROFILE_GDRAW,
00108     CAMPROFILE_SHADOW,
00109     CAMPROFILE_BEVEL,
00110     CAMPROFILE_BLIT,
00111 
00112     CAMPROFILE_NONE             // Must be the last in the list
00113 } CamProfileMode;
00114 
00115 class CamProfiler;
00116 
00117 /*******************************************************************************************
00118 
00119 >   class CamProfile : public CCObject
00120 
00121     Author:     Alex_Bligh <alex@alex.org.uk>
00122     Created:    24/11/2005
00123     Purpose:    To time various bits of the Camelot subsytem
00124     Notes:      In the OIL
00125     See Also:   CamProfiler
00126 
00127 This class allows a limited degree of built in profiling of Camelot operations.
00128 
00129 Around something you want to time, construct a new CamProfile object
00130 
00131 So for instance:
00132 
00133     void myslowfunc()
00134     {
00135     ... do something ...
00136     CamProfile myCamProfile(CAMPROFILE_MYSLOWFUNC)l
00137 
00138     ... do the thing you want timed ...
00139 
00140     // Object destroyed as it goes out of scope.
00141     }
00142 
00143 Note that you do not need a specific destructor. We cope with nested profiles in the
00144 obvious manner. When an exception is thrown, Camelot at various points cleans off the
00145 list of nested profiles. This may make them inaccurate.
00146 
00147 ********************************************************************************************/
00148 
00149 
00150 class CamProfile : public CCObject
00151 {
00152     CC_DECLARE_DYNCREATE( CamProfile )
00153 
00154     friend class CamProfiler;
00155 
00156 public:
00157     CamProfile(CamProfileMode myMode = CAMPROFILE_NONE );
00158     virtual ~CamProfile();
00159 
00160     void SetMode(CamProfileMode myMode, BOOL Base = FALSE);
00161 
00162     static BOOL Init();
00163     static BOOL ClearList();
00164     static BOOL ResetCounters();
00165     static BOOL ActivateProfiling(BOOL Run = TRUE);
00166     static void AtBase(CamProfileMode myMode=CAMPROFILE_NONE);
00167     static void UpdateOilTimes();
00168     static void GetTimeString(TCHAR * pTime, UINT32 length);
00169 
00170 private:
00171     // Prev and next pointers - don't use list class for speed and as lists are one obvious
00172     // thing we might wish to profile
00173     CamProfile* pPrev; // The next one on the list
00174     CamProfile* pNext; // The previous one the list
00175 
00176     CamProfileMode Mode;
00177 
00178     static CamProfile* pHead; // The head of the list
00179     static CamProfile* pTail; // The tail of the list
00180     static CamProfile* pCurrent; // The current profiler - almost inevitably the tail unless it's not running
00181 
00182     static BOOL Running;    
00183     static BOOL Inited;
00184 
00185     static CamProfile * OurHead; // Base member we allocate and thus can free
00186 
00187     UINT64 OilTime;
00188     static UINT64 LastOilTime;
00189 
00190     BOOL Zombie;    // Set on objects created whilst profiling isn't running
00191 
00192     static UINT64 OilTimeArray[CAMPROFILE_NONE];
00193 
00194 };
00195 
00196 /*******************************************************************************************
00197 
00198 >   class CamProfiler : public CCObject
00199 
00200     Author:     Alex_Bligh <alex@alex.org.uk>
00201     Created:    24/11/2005
00202     Purpose:    To report on time taken in various CamProfile sections
00203     Notes:      In the OIL
00204     See Also:   CamProfile
00205 
00206 This class allows the user to maintain a set of timers that will be updated depending
00207 on the time spent in Camelot in various CamProfile sections (see header for CamProfile).
00208 
00209 To use:
00210     CamProfiler myProfile;
00211 
00212     ... do some stuff ...
00213 
00214     double results[CAMPROFILE_NONE]
00215     myProfile->Read(results); // Read results in microseconds
00216 
00217 All this class actually does is store the values of CamProfile::OilTimeArray array
00218 when it's created, Read() then performs a subtraction to give the elapsed time
00219 in each element.
00220 
00221 ********************************************************************************************/
00222 
00223 
00224 class CamProfiler : public CCObject
00225 {
00226     CC_DECLARE_DYNCREATE( CamProfiler )
00227 
00228 public:
00229     CamProfiler();
00230 
00231     void Reset();
00232     double Read(double Results[CAMPROFILE_NONE]);
00233 
00234 private:
00235     UINT64 OilTimeArray[CAMPROFILE_NONE];
00236     UINT64 FirstOilTime;
00237 };
00238 
00239 
00240 #endif
00241 

Generated on Sat Nov 10 03:48:10 2007 for Camelot by  doxygen 1.4.4