Added verbose mode to CrossBench

This commit is contained in:
2015-06-13 16:23:26 +03:00
parent 010ad6577f
commit 14273b46a3

View File

@@ -22,6 +22,8 @@ static const wxCmdLineEntryDesc cmdLineDesc[] = {
wxCMD_LINE_VAL_NUMBER }, wxCMD_LINE_VAL_NUMBER },
{ wxCMD_LINE_SWITCH, wxT("r"), wxT("rand"), wxT("enables generating random crosswords"), { wxCMD_LINE_SWITCH, wxT("r"), wxT("rand"), wxT("enables generating random crosswords"),
wxCMD_LINE_VAL_NONE }, wxCMD_LINE_VAL_NONE },
{ wxCMD_LINE_SWITCH, wxT("v"), wxT("verbose"), wxT("enables verbose mode"),
wxCMD_LINE_VAL_NONE },
{ wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("show this help message"), { wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("show this help message"),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_NONE } { wxCMD_LINE_NONE }
@@ -37,7 +39,9 @@ int main(int argc, char **argv) {
long run_count = 10; long run_count = 10;
wxString grid_path, dict_path; wxString grid_path, dict_path;
bool is_rand = false; bool is_rand = false;
bool is_verbose = false;
switch ( cmd_parser.Parse() ) { switch ( cmd_parser.Parse() ) {
case -1: case -1:
@@ -45,6 +49,7 @@ int main(int argc, char **argv) {
case 0: case 0:
cmd_parser.Found(wxT("count"), &run_count); cmd_parser.Found(wxT("count"), &run_count);
is_rand = cmd_parser.Found(wxT("rand")); is_rand = cmd_parser.Found(wxT("rand"));
is_verbose = cmd_parser.Found(wxT("verbose"));
grid_path = cmd_parser.GetParam(0); grid_path = cmd_parser.GetParam(0);
dict_path = cmd_parser.GetParam(1); dict_path = cmd_parser.GetParam(1);
wxLogDebug(wxT("grid_path = ") + grid_path + wxT("\n")); wxLogDebug(wxT("grid_path = ") + grid_path + wxT("\n"));
@@ -72,8 +77,11 @@ int main(int argc, char **argv) {
durs.at(i) = wxGetLocalTimeMillis(); durs.at(i) = wxGetLocalTimeMillis();
generateCross(grid,dict,words_out); generateCross(grid,dict,words_out);
if ( words_out.size() == 0 ) if ( words_out.size() == 0 )
wxPrintf(wxT("Error in creating crossword #%l!\n"),i); wxPrintf(wxT("Error in creating #%i!\n"),i+1);
durs.at(i) = wxGetLocalTimeMillis() - durs.at(i); durs.at(i) = wxGetLocalTimeMillis() - durs.at(i);
if ( is_verbose )
wxPrintf(wxT("Time to generate #%i is ")
+ durs.at(i).ToString() + wxT(" ms\n"), i+1);
} }
wxLongLong tm_total = std::accumulate(durs.begin(),durs.end(), wxLongLong(0,0)); wxLongLong tm_total = std::accumulate(durs.begin(),durs.end(), wxLongLong(0,0));
wxLongLong tm_mean = (tm_total + run_count/2) / run_count; wxLongLong tm_mean = (tm_total + run_count/2) / run_count;