Audacity  2.2.2
Diags.cpp
Go to the documentation of this file.
1 
2 /**********************************************************************
3 
4  Audacity: A Digital Audio Editor
5 
6  Diags.cpp
7 
8  James Crook
9 
10 
11 ********************************************************************//********************************************************************/
29 
30 
31 #include "Audacity.h"
32 #include <wx/defs.h>
33 #include <wx/hash.h>
34 #include <wx/intl.h>
35 #include <wx/log.h>
36 
37 #include <wx/stopwatch.h>
38 #include "Diags.h"
39 
40 static wxStopWatch MasterWatch;
41 static bool bStopWatchStarted = false;
42 
44  wxLog * pLog = wxLog::SetActiveTarget(NULL);
45  // this macro is empty if wxWidgets is not compiled in debug mode
46  wxLogDebug( wxT("%s"), pDiag->pMessage );
47  wxLog::SetActiveTarget(pLog);
48 }
49 void diagnostics_do_diag_mem( t_diag_struct * pDiag, long amount ){
50  wxLog * pLog = wxLog::SetActiveTarget(NULL);
51  wxLogDebug( wxT("%s %l"), pDiag->pMessage, amount );
52  wxLog::SetActiveTarget(pLog);
53  pDiag->total += amount;
54  pDiag->most_recent = amount;
55  if( pDiag->countdown == (pDiag->initial_count -1 )){
56  pDiag->most = amount;
57  pDiag->least = amount;
58  }
59  else if( amount > pDiag->most )
60  pDiag->most = amount;
61  else if( amount < pDiag->least )
62  pDiag->least = amount;
63 }
64 
66  if( *pRememberMe == NULL ){
67  *pRememberMe = pDiag;
68  if( !bStopWatchStarted ){
69  bStopWatchStarted = true;
70  MasterWatch.Start();
71  }
72  }
73  pDiag->most_recent = MasterWatch.Time();
74 }
75 
77  t_diag_struct * pDiag = *ppDiag;
78  *ppDiag = NULL;
79  long amount = MasterWatch.Time() - pDiag->most_recent;
80  pDiag->total += amount;
81  pDiag->most_recent = amount;
82  if( pDiag->countdown == (pDiag->initial_count -1 )){
83  pDiag->most = amount;
84  pDiag->least = amount;
85  }
86  else if( amount > pDiag->most )
87  pDiag->most = amount;
88  else if( amount < pDiag->least )
89  pDiag->least = amount;
90  wxLog * pLog = wxLog::SetActiveTarget(NULL);
91  wxLogDebug( wxT("%s %f seconds"), pDiag->pMessage, ((float)amount)/1000.0f );
92  wxLog::SetActiveTarget(pLog);
93 }
94 
95 
97  DIAG("Flip counter");// Flip counter will show in log ten times, then just count.
98 }
long most_recent
Definition: Diags.h:24
const wchar_t * pMessage
Definition: Diags.h:27
long initial_count
Definition: Diags.h:22
long countdown
Definition: Diags.h:21
long total
Definition: Diags.h:23
#define DIAG(message)
Definition: Diags.h:57
long most
Definition: Diags.h:26
void diagnostics_do_perfmon_start(t_diag_struct *pDiag, t_diag_struct **pRememberMe)
Definition: Diags.cpp:65
long least
Definition: Diags.h:25
void diag_sample_test()
Definition: Diags.cpp:96
void diagnostics_do_diag_mem(t_diag_struct *pDiag, long amount)
Definition: Diags.cpp:49
void diagnostics_do_diag(t_diag_struct *pDiag)
Definition: Diags.cpp:43
static wxStopWatch MasterWatch
Definition: Diags.cpp:40
void diagnostics_do_perfmon_stop(t_diag_struct **ppDiag)
Definition: Diags.cpp:76
static bool bStopWatchStarted
Definition: Diags.cpp:41