mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-21 06:01:13 +02:00
Added DIAG macros for countdown logging
Also for tracking memory use and for timing.
This commit is contained in:
91
src/Diags.cpp
Normal file
91
src/Diags.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
Diags.cpp
|
||||
|
||||
James Crook
|
||||
|
||||
|
||||
********************************************************************//**
|
||||
|
||||
\class Diags
|
||||
\brief Processing of the macros for recording bad events or performance
|
||||
monitoring.
|
||||
|
||||
The idea of these macros is that we can include them in release
|
||||
code at no risk. They
|
||||
|
||||
a) have almost zero performance impact.
|
||||
b) will not flood the log with events.
|
||||
|
||||
This is achieved by a countdown which stops recording in the log
|
||||
when the countdown is finished. The countdwon continues to
|
||||
count down so that we track how many times the event happens.
|
||||
|
||||
|
||||
*//********************************************************************/
|
||||
|
||||
|
||||
#include "Audacity.h"
|
||||
#include <wx/defs.h>
|
||||
#include <wx/hash.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/log.h>
|
||||
|
||||
#include <wx/stopwatch.h>
|
||||
#include "Diags.h"
|
||||
#include "Experimental.h"
|
||||
|
||||
static wxStopWatch MasterWatch;
|
||||
static bool bStopWatchStarted = false;
|
||||
|
||||
void diagnostics_do_diag( t_diag_struct * pDiag ){
|
||||
wxLogDebug( wxT("%s"), pDiag->pMessage );
|
||||
}
|
||||
void diagnostics_do_diag_mem( t_diag_struct * pDiag, long amount ){
|
||||
wxLogDebug( wxT("%s %l"), pDiag->pMessage, amount );
|
||||
pDiag->total += amount;
|
||||
pDiag->most_recent = amount;
|
||||
if( pDiag->countdown == (pDiag->initial_count -1 )){
|
||||
pDiag->most = amount;
|
||||
pDiag->least = amount;
|
||||
}
|
||||
else if( amount > pDiag->most )
|
||||
pDiag->most = amount;
|
||||
else if( amount < pDiag->least )
|
||||
pDiag->least = amount;
|
||||
}
|
||||
|
||||
void diagnostics_do_perfmon_start( t_diag_struct * pDiag, t_diag_struct ** pRememberMe ){
|
||||
if( *pRememberMe == NULL ){
|
||||
*pRememberMe = pDiag;
|
||||
if( !bStopWatchStarted ){
|
||||
bStopWatchStarted = true;
|
||||
MasterWatch.Start();
|
||||
}
|
||||
}
|
||||
pDiag->most_recent = MasterWatch.Time();
|
||||
}
|
||||
|
||||
void diagnostics_do_perfmon_stop( const char * pMessage, t_diag_struct ** ppDiag ){
|
||||
t_diag_struct * pDiag = *ppDiag;
|
||||
*ppDiag = NULL;
|
||||
long amount = MasterWatch.Time() - pDiag->most_recent;
|
||||
pDiag->total += amount;
|
||||
pDiag->most_recent = amount;
|
||||
if( pDiag->countdown == (pDiag->initial_count -1 )){
|
||||
pDiag->most = amount;
|
||||
pDiag->least = amount;
|
||||
}
|
||||
else if( amount > pDiag->most )
|
||||
pDiag->most = amount;
|
||||
else if( amount < pDiag->least )
|
||||
pDiag->least = amount;
|
||||
}
|
||||
|
||||
|
||||
void diag_sample_test(){
|
||||
DIAG("Flip counter");// Flip counter will show in log ten times, then just count.
|
||||
}
|
Reference in New Issue
Block a user