wxArt2D
prflcnthstg.cpp
1 /*! \file general/src/prflcnthstg.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: prflcnthstg.cpp,v 1.2 2005/06/27 19:52:43 titato Exp $
10 */
11 
12 ///////////////////////////////////////////////////////////////////////////////
13 //
14 // .h Includedateien
15 // In diesen Dateien darf kein Aufruf von new erfolgen
16 //
17 ///////////////////////////////////////////////////////////////////////////////
18 
19 #include "a2dprec.h"
20 
21 #ifdef __BORLANDC__
22 #pragma hdrstop
23 #endif
24 
25 #ifndef WX_PRECOMP
26 #include "wx/wx.h"
27 #endif
28 
29 #include "wx/genart/prfl.h"
30 
31 #include "wx/genart/prflcnthstg.h"
32 
33 ///////////////////////////////////////////////////////////////////////////////
34 //
35 // .inl Includedateien
36 // In diesen Dateien darf kein new Operator deklariert werden
37 //
38 ///////////////////////////////////////////////////////////////////////////////
39 
40 ///////////////////////////////////////////////////////////////////////////////
41 //
42 // Speicherschutz unter Debug fuer Implemenatation
43 //
44 ///////////////////////////////////////////////////////////////////////////////
45 
46 #ifdef _DEBUG
47 #undef THIS_FILE
48 static char THIS_FILE[] = __FILE__;
49 #endif
50 
51 //*****************************************************************************
52 //*
53 //* Klasse a2dProfilerHistogram: Erzeugungs und Vernichtungsoperatoren
54 //*
55 //*****************************************************************************
56 
57 ///////////////////////////////////////////////////////////////////////////////
58 //
59 // Standard-Erzeugungsoperator
60 //
61 ///////////////////////////////////////////////////////////////////////////////
62 
63 a2dProfilerHistogram::a2dProfilerHistogram( wxString idIn, int hstgMinIn, int hstgMaxIn )
64  : a2dProfiler( idIn )
65 {
66  hstgMin = hstgMinIn;
67  hstgMax = hstgMaxIn;
68 
69  cntLess = 0;
70  cntAbv = 0;
71  cnt = new unsigned long[hstgMax - hstgMin + 1];
72  for( int i = hstgMin; i <= hstgMax; i++ ) cnt[i - hstgMin] = 0;
73  wxASSERT( cnt );
74 }
75 
76 ///////////////////////////////////////////////////////////////////////////////
77 //
78 // Vernichtungsoperator
79 //
80 ///////////////////////////////////////////////////////////////////////////////
81 
83 {
84  OpenPrflFile();
85 
86  if( !prflFile.IsOpened() )
87  return;
88 
89  unsigned int
90  intg = 0;
91  unsigned int
92  n = 0;
93  double
94  sum = 0,
95  sumSqr = 0;
96 
97  wxString stro;
98 
99  intg += cntLess;
100  stro.Printf( wxT( "%-20s|%10d|intg: %10d| unterhalb\n" ),
101  id.c_str(),
102  cntLess,
103  intg
104  );
105  prflFile.Write( stro );
106 
107 
108  for( int i = hstgMin; i <= hstgMax; i++ )
109  {
110  intg += cnt[i - hstgMin];
111  n += cnt[i - hstgMin];
112  sum += cnt[i - hstgMin] * double( i );
113  sumSqr += cnt[i - hstgMin] * double( i ) * double( i );
114  stro.Printf( wxT( "%-20s|%10d|intg: %10d|%10d\n" ),
115  id.c_str(),
116  cnt[i - hstgMin],
117  intg,
118  i
119  );
120  prflFile.Write( stro );
121 
122  }
123 
124  intg += cntAbv;
125  stro.Printf( wxT( "%-20s|%10d|intg: %10d| oberhalb\n" ),
126  id.c_str(),
127  cntAbv,
128  intg
129  );
130  prflFile.Write( stro );
131 
132  stro.Printf( wxT( "%-20s|Summe x %20.3lf\n" ),
133  id.c_str(),
134  sum
135  );
136  prflFile.Write( stro );
137  stro.Printf( wxT( "%-20s|Mittelwert x %20.3lf\n" ),
138  id.c_str(),
139  sum / n
140  );
141  prflFile.Write( stro );
142  stro.Printf( wxT( "%-20s|Mittelwert x^2 %20.3lf\n\n" ),
143  id.c_str(),
144  sumSqr / n
145  );
146  prflFile.Write( stro );
147 
148  wxASSERT( cnt );
149 
150  delete [] cnt;
151 }
152 
153 //*****************************************************************************
154 //*
155 //* Klasse a2dProfilerHistogram: Zugriffsfunktionen
156 //*
157 //*****************************************************************************
158 
159 //*****************************************************************************
160 //*
161 //* Klasse a2dProfilerHistogram: Verarbeitungsfunktionen
162 //*
163 //*****************************************************************************
164 
165 //*****************************************************************************
166 //*
167 //* Klasse a2dProfilerHistogram: interne Funktionen
168 //*
169 //*****************************************************************************
170 
171 //*****************************************************************************
172 //*
173 //* Klasse a2dProfilerHistogram: statische Variablen
174 //*
175 //*****************************************************************************
static void OpenPrflFile()
opens the profiling data file, if not yet open.
Definition: prfl.cpp:99
a2dProfilerHistogram(wxString idIn, int hstgMinIn, int hstgMaxIn)
constructor
Definition: prflcnthstg.cpp:63
~a2dProfilerHistogram()
destructor
Definition: prflcnthstg.cpp:82
profiling classes
profiling classes
prflcnthstg.cpp Source File -- Sun Oct 12 2014 17:04:23 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation