From 14273b46a3776988756271047b988ca32ad2ff6b Mon Sep 17 00:00:00 2001 From: Aleksey Lobanov Date: Sat, 13 Jun 2015 16:23:26 +0300 Subject: [PATCH] Added verbose mode to CrossBench --- CrossBench/main.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/CrossBench/main.cpp b/CrossBench/main.cpp index 60ee57a..e3e1300 100644 --- a/CrossBench/main.cpp +++ b/CrossBench/main.cpp @@ -18,9 +18,11 @@ static const wxCmdLineEntryDesc cmdLineDesc[] = { wxCMD_LINE_VAL_STRING }, { wxCMD_LINE_PARAM, wxT(""), wxT(""), wxT("dict_path"), wxCMD_LINE_VAL_STRING }, - { wxCMD_LINE_OPTION, wxT("c"), wxT("count"), wxT("times to run generation, default = 10") , + { wxCMD_LINE_OPTION, wxT("c"), wxT("count"), wxT("times to run generation, default = 10"), 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_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_VAL_NONE, wxCMD_LINE_OPTION_HELP }, @@ -37,16 +39,19 @@ int main(int argc, char **argv) { long run_count = 10; wxString grid_path, dict_path; - bool is_rand = false; + + bool is_rand = false; + bool is_verbose = false; switch ( cmd_parser.Parse() ) { case -1: return 0; case 0: cmd_parser.Found(wxT("count"), &run_count); - is_rand = cmd_parser.Found(wxT("rand")); - grid_path = cmd_parser.GetParam(0); - dict_path = cmd_parser.GetParam(1); + is_rand = cmd_parser.Found(wxT("rand")); + is_verbose = cmd_parser.Found(wxT("verbose")); + grid_path = cmd_parser.GetParam(0); + dict_path = cmd_parser.GetParam(1); wxLogDebug(wxT("grid_path = ") + grid_path + wxT("\n")); wxLogDebug(wxT("dict_path = ") + dict_path + wxT("\n")); wxLogDebug(wxT("run_count = %d\n"), run_count); @@ -72,8 +77,11 @@ int main(int argc, char **argv) { durs.at(i) = wxGetLocalTimeMillis(); generateCross(grid,dict,words_out); 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); + 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_mean = (tm_total + run_count/2) / run_count;