Added a capability to turn off all printing of timings. This is

helpful for the test suite.
This commit is contained in:
Harry Moffat 2008-01-24 18:01:48 +00:00
parent 4c7f7b6c30
commit 1991e534a4
6 changed files with 68 additions and 33 deletions

View file

@ -42,6 +42,7 @@ using namespace std;
namespace VCSnonideal {
vcs_MultiPhaseEquil::vcs_MultiPhaseEquil() :
m_vprob(0),
m_mix(0),
@ -710,7 +711,9 @@ namespace VCSnonideal {
plogf("------------------------------------------"
"-------------------\n");
if (printLvl > 2) {
plogf("Total time = %12.6e seconds\n", te);
if (m_vsolvePtr->m_timing_print_lvl > 0) {
plogf("Total time = %12.6e seconds\n", te);
}
}
}
return iSuccess;

View file

@ -182,6 +182,7 @@ namespace Cantera {
namespace VCSnonideal {
class VCS_PROB;
class VCS_SOLVE;

View file

@ -32,6 +32,15 @@ namespace VCSnonideal {
*/
#define plogf Cantera::writelogf
//! Global hook for turning on and off time printing.
/*!
* Default is to allow printing. But, you can assign this to zero
* globally to turn off all time printing.
* This is helpful for test suite purposes where you are interested
* in differences in text files.
*/
extern int vcs_timing_print_lvl;
/*
* Forward references
*/

View file

@ -348,11 +348,17 @@ int VCS_SOLVE::vcs_report(int iconv)
*/
plogf("\n");
plogf("\nCounters: Iterations Time (seconds)\n");
plogf(" vcs_basopt: %5d %11.5E\n",
m_VCount->Basis_Opts, m_VCount->Time_basopt);
plogf(" vcs_TP: %5d %11.5E\n",
m_VCount->Its, m_VCount->Time_vcs_TP);
if (m_timing_print_lvl > 0) {
plogf(" vcs_basopt: %5d %11.5E\n",
m_VCount->Basis_Opts, m_VCount->Time_basopt);
plogf(" vcs_TP: %5d %11.5E\n",
m_VCount->Its, m_VCount->Time_vcs_TP);
} else {
plogf(" vcs_basopt: %5d %11s\n",
m_VCount->Basis_Opts," NA ");
plogf(" vcs_TP: %5d %11s\n",
m_VCount->Its," NA " );
}
print_line("-", 80);
print_line("-", 80);
@ -373,7 +379,7 @@ int VCS_SOLVE::vcs_report(int iconv)
/*****************************************************************************/
/*****************************************************************************/
void VCS_SOLVE::vcs_TCounters_report(void)
void VCS_SOLVE::vcs_TCounters_report(int timing_print_lvl)
/**************************************************************************
*
@ -382,15 +388,26 @@ void VCS_SOLVE::vcs_TCounters_report(void)
* Print out the total Its and time counters to standard output
***************************************************************************/
{
plogf("\nTCounters: Num_Calls Total_Its Total_Time (seconds)\n");
plogf(" vcs_basopt: %5d %5d %11.5E\n",
m_VCount->T_Basis_Opts, m_VCount->T_Basis_Opts, m_VCount->T_Time_basopt);
plogf(" vcs_TP: %5d %5d %11.5E\n",
m_VCount->T_Calls_vcs_TP, m_VCount->T_Its, m_VCount->T_Time_vcs_TP);
plogf(" vcs_inest: %5d %11.5E\n",
m_VCount->T_Calls_Inest, m_VCount->T_Time_inest);
plogf(" vcs_TotalTime: %11.5E\n",
plogf("\nTCounters: Num_Calls Total_Its Total_Time (seconds)\n");
if (timing_print_lvl > 0) {
plogf(" vcs_basopt: %5d %5d %11.5E\n",
m_VCount->T_Basis_Opts, m_VCount->T_Basis_Opts, " NA ");
plogf(" vcs_TP: %5d %5d %11.5E\n",
m_VCount->T_Calls_vcs_TP, m_VCount->T_Its, " NA ");
plogf(" vcs_inest: %5d %11.5E\n",
m_VCount->T_Calls_Inest, " NA ");
plogf(" vcs_TotalTime: %11.5E\n",
m_VCount->T_Time_vcs);
} else {
plogf(" vcs_basopt: %5d %5d %11s\n",
m_VCount->T_Basis_Opts, m_VCount->T_Basis_Opts," NA ");
plogf(" vcs_TP: %5d %5d %11s\n",
m_VCount->T_Calls_vcs_TP, m_VCount->T_Its," NA ");
plogf(" vcs_inest: %5d %11s\n",
m_VCount->T_Calls_Inest, " NA ");
plogf(" vcs_TotalTime: %11s\n",
" NA ");
}
}
/*****************************************************************************/

View file

@ -29,6 +29,8 @@ using namespace std;
namespace VCSnonideal {
int VCSnonideal::vcs_timing_print_lvl = 1;
VCS_SOLVE::VCS_SOLVE() :
NSPECIES0(0),
NPHASE0(0),
@ -52,9 +54,8 @@ namespace VCSnonideal {
Vol(0.0),
Faraday_dim(1.602e-19 * 6.022136736e26),
m_VCount(0),
#ifdef DEBUG_MODE
vcs_debug_print_lvl(0),
#endif
m_timing_print_lvl(1),
m_VCS_UnitsFormat(VCS_UNITS_UNITLESS)
{
}
@ -211,7 +212,10 @@ namespace VCSnonideal {
m_VCount = new VCS_COUNTERS();
vcs_counters_init(1);
if (vcs_timing_print_lvl == 0) {
m_timing_print_lvl = 0;
}
return;
}
@ -281,23 +285,22 @@ namespace VCSnonideal {
*
* @param maxit Maximum number of iterations for the algorithm
*
* @param iprintTime Printing of time information. Default = -1,
* implies printing if other printing is turned on.
*
* Output:
*
* @return
* nonzero value: failure to solve the problem at hand.
* zero : success
*/
int VCS_SOLVE::vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit,
int iprintTime) {
int VCS_SOLVE::vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit) {
int retn = 0;
int iconv = 0, nspecies0, nelements0, nphase0;
Cantera::clockWC tickTock;
if (iprintTime == -1) {
iprintTime = MAX(ipr, ip1);
int iprintTime = MAX(ipr, ip1);
if (m_timing_print_lvl < iprintTime) {
iprintTime = m_timing_print_lvl ;
}
if (ifunc < 0 || ifunc > 2) {
plogf("vcs: Unrecognized value of ifunc, %d: bailing!\n",
ifunc);
@ -414,7 +417,7 @@ namespace VCSnonideal {
double te = tickTock.secondsWC();
m_VCount->T_Time_vcs += te;
if (iprintTime > 0) {
vcs_TCounters_report();
vcs_TCounters_report(m_timing_print_lvl);
}
/*
* Now, destroy the private data, if requested to do so

View file

@ -90,18 +90,13 @@ public:
*
* @param maxit Maximum number of iterations for the algorithm
*
* @param iprintTime Printing of time information. Default = -1,
* implies printing if other printing is turned
* on.
*
* Output:
*
* @return
* nonzero value: failure to solve the problem at hand.
* zero : success
*/
int vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit,
int iprintTime = -1);
int vcs(VCS_PROB *vprob, int ifunc, int ipr, int ip1, int maxit);
int vcs_solve_TP(int, int, int);
@ -324,7 +319,7 @@ private:
*/
void vcs_counters_init(int ifunc);
void vcs_TCounters_report(void);
void vcs_TCounters_report(int timing_print_lvl = 1);
public:
//! value of the number of species used to malloc data structures
@ -781,6 +776,13 @@ public:
int vcs_debug_print_lvl;
//! printing level of timing information
/*!
* 1 allowing printing of timing
* 0 do not allow printing of timing -> everything is a zero.
*/
int m_timing_print_lvl;
//! Units for the chemical potential data:
/*!
* VCS_UnitsFormat = Units for the chemical potential data: