diff --git a/CrossBench/CrossBench.project b/CrossBench/CrossBench.project index abeb01b..683ce53 100644 --- a/CrossBench/CrossBench.project +++ b/CrossBench/CrossBench.project @@ -83,7 +83,7 @@ - + diff --git a/CrossBench/main.cpp b/CrossBench/main.cpp index 8617b3a..506ed81 100644 --- a/CrossBench/main.cpp +++ b/CrossBench/main.cpp @@ -2,6 +2,7 @@ #include #include +//#include #include "crossbasetypes.hpp" #include "crossgen.hpp" @@ -10,13 +11,11 @@ * Console app that runs generating of crosswords * with random or not. And if yes with command-line parametrs we can * set number of tests and get - * 1. Worst, Best - * 2. Mean * 3. Dispersion */ static const wxCmdLineEntryDesc cmdLineDesc[] = { - { wxCMD_LINE_PARAM , wxT(""), wxT(""), wxT("cross_path"), + { wxCMD_LINE_PARAM , wxT(""), wxT(""), wxT("grid_path"), wxCMD_LINE_VAL_STRING }, { wxCMD_LINE_PARAM, wxT(""), wxT(""), wxT("dict_path"), wxCMD_LINE_VAL_STRING }, @@ -35,22 +34,40 @@ int main(int argc, char **argv) { } wxCmdLineParser cmd_parser(cmdLineDesc, argc, argv); long run_count = 10; - wxString cross_path, dict_path; + wxString grid_path, dict_path; switch ( cmd_parser.Parse() ) { case -1: return 0; case 0: cmd_parser.Found(wxT("count"), &run_count); - cross_path = cmd_parser.GetParam(0); + grid_path = cmd_parser.GetParam(0); dict_path = cmd_parser.GetParam(1); - wxPrintf(wxT("cross_path = ") + cross_path + wxT("\n")); - wxPrintf(wxT("dict_path = ") + dict_path + wxT("\n")); - wxPrintf(wxT("run_count = %d\n"), run_count); + wxLogDebug(wxT("grid_path = ") + grid_path + wxT("\n")); + wxLogDebug(wxT("dict_path = ") + dict_path + wxT("\n")); + wxLogDebug(wxT("run_count = %d\n"), run_count); break; default: return 0; } + std::vector< wxLongLong > durs(run_count); // durations + std::vector< wxString > words_out; + DictType dict; + GridType grid; + readDict(dict_path, dict); + readGrid(grid_path, grid); + for (long i = 0; i < run_count; ++i) { + words_out.clear(); + durs.at(i) = wxGetLocalTimeMillis(); + generateCross(grid,dict,words_out); + if ( words_out.size() == 0 ) + wxPrintf(wxT("Error in creating crossword #%l!\n"),i); + durs.at(i) = wxGetLocalTimeMillis() - durs.at(i); + } + wxLongLong tm_total = std::accumulate(durs.begin(),durs.end(), wxLongLong(0,0)); + wxLongLong tm_mean = tm_total / run_count; + wxPrintf(wxT("Total time = ") + tm_total.ToString() + wxT(" ms.\nMean time = ") + + tm_mean.ToString() + wxT(" ms.\n")); return 0; } diff --git a/src/crossgen.hpp b/src/crossgen.hpp index 81b8836..15eb03d 100644 --- a/src/crossgen.hpp +++ b/src/crossgen.hpp @@ -24,8 +24,6 @@ void readDict(const wxString path, DictType &dict){ val = str.Right(str.size() - del_ind - 2); dict[key] = val; } - wxLogDebug(wxString::Format(wxT("Прочитан словарь размером %d записей"), - static_cast(dict.size()))); f.Close(); }; @@ -167,7 +165,6 @@ bool procCross(UsedWords used, AllWordsType &words, CurGridType grid, } if (procCross(t_used, words, t_grid, winfos, cur_word_ind + 1, out)){ - wxLogDebug(cur_word); out.push_back(cur_word); return true; } @@ -183,9 +180,6 @@ void generateCross(GridType &grid, const DictType &dict, std::vector & words.resize(it->first.size() + 2); words.at(it->first.size()).push_back(it->first); } - for (size_t i = 2; i < words.size(); ++i){ - wxLogDebug(wxT("Number of words with length %d is %d"), i, words.at(i).size()); - } std::vector winfos; generateWordInfo(grid, winfos); for (size_t i = 0; i < winfos.size(); ++i) diff --git a/wxCrossGen/wxCrossGen.project b/wxCrossGen/wxCrossGen.project index 41deef3..cc23c68 100644 --- a/wxCrossGen/wxCrossGen.project +++ b/wxCrossGen/wxCrossGen.project @@ -112,7 +112,7 @@ - +