wxArt2D
prfltmr.cpp
1 /*! \file general/src/prfltmr.cpp
2  \author Michael Sögtrop
3  \date Created 08/05/2004
4 
5  Copyright: 2004-2004 (c) Michael Sögtrop
6 
7  Licence: wxWidgets Licence
8 
9  RCS-ID: $Id: prfltmr.cpp,v 1.3 2005/08/12 21:21:48 titato Exp $
10 */
11 
12 #include "a2dprec.h"
13 
14 #ifdef __BORLANDC__
15 #pragma hdrstop
16 #endif
17 
18 #ifndef WX_PRECOMP
19 #include "wx/wx.h"
20 #endif
21 
22 #include "wx/genart/prfl.h"
23 #include "wx/genart/prfltmr.h"
24 
25 ///////////////////////////////////////////////////////////////////////////////
26 //
27 // .inl Includedateien
28 // In diesen Dateien darf kein new Operator deklariert werden
29 //
30 ///////////////////////////////////////////////////////////////////////////////
31 
32 ///////////////////////////////////////////////////////////////////////////////
33 //
34 // Speicherschutz unter Debug fuer Implemenatation
35 //
36 ///////////////////////////////////////////////////////////////////////////////
37 
38 #ifdef _DEBUG
39 #undef THIS_FILE
40 static char THIS_FILE[] = __FILE__;
41 #endif
42 
43 //*****************************************************************************
44 //*
45 //* Klasse a2dProfilerTimer: Erzeugungs und Vernichtungsoperatoren
46 //*
47 //*****************************************************************************
48 
49 ///////////////////////////////////////////////////////////////////////////////
50 //
51 // Standard-Erzeugungsoperator
52 //
53 ///////////////////////////////////////////////////////////////////////////////
54 
55 a2dProfilerTimer::a2dProfilerTimer( const wxString& idIn )
56  : a2dProfiler( idIn )
57 {
58  cnt = 0;
59  time = 0;
60 }
61 
63 {
64  OpenPrflFile();
65 
66  if( !prflFile.IsOpened() )
67  return;
68  wxString stro;
69  stro.Printf( wxT( "%-20s|%10lu|%16.6lf|%16.0lf\n" ),
70  id.c_str(),
71  cnt,
72  double( time ) * 1e-9,
73  double( time ) / cnt
74  );
75 }
76 
77 ///////////////////////////////////////////////////////////////////////////////
78 //
79 // Wird am Anfang eines Blocks aufgerufen
80 //
81 ///////////////////////////////////////////////////////////////////////////////
82 
84 {
85 // On fedora you defined(i386) could be used, but sus does not like it.
86 // _X86_ only detects mingw/cygwin.
87 #if defined(__GNUG__) && ( defined(_X86_))
88  register __int64 TSC asm( "eax" );
89  asm volatile ( "rdtsc" : : : "eax", "edx" );
90  time -= TSC;
91 #elif defined(__VISUALC__)
92  enum
93  {
94  timeOffs = offsetof( a2dProfilerTimer, time )
95  };
96 
97  __asm
98  {
99  _emit 0x0F;
100  _emit 0x31;
101  sub [ecx+timeOffs], EAX
102  sbb [ecx+timeOffs+4], EDX
103  }
104  cnt++;
105 #else
106 #warning Profile timer not (yet) supported on this system
107 #endif
108 }
109 
110 ///////////////////////////////////////////////////////////////////////////////
111 //
112 // Wird am Ende eines Blocks aufgerufen
113 //
114 ///////////////////////////////////////////////////////////////////////////////
115 
117 {
118 #if defined(__GNUG__) && ( defined(_X86_))
119  register __int64 TSC asm( "eax" );
120  asm volatile ( "rdtsc" : : : "eax", "edx" );
121  time += TSC;
122 #elif defined(__VISUALC__)
123  enum
124  {
125  timeOffs = offsetof( a2dProfilerTimer, time )
126  };
127  __asm
128  {
129  _emit 0x0F;
130  _emit 0x31;
131  add [ecx+timeOffs], EAX
132  adc [ecx+timeOffs+4], EDX
133  }
134 #endif
135 }
136 
void EndBlck()
is called at the end of a scope
Definition: prfltmr.cpp:116
profile timer
Definition: prfltmr.h:76
static void OpenPrflFile()
opens the profiling data file, if not yet open.
Definition: prfl.cpp:99
void BgnBlck()
is called at the start of a scope
Definition: prfltmr.cpp:83
a2dProfilerTimer(const wxString &idIn)
constructor
Definition: prfltmr.cpp:55
profiling classes
~a2dProfilerTimer()
destructor
Definition: prfltmr.cpp:62
profiling classes
prfltmr.cpp Source File -- Sun Oct 12 2014 17:04:23 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation