Added switcher to CrossBench for enabling random. It is default disabled

This commit is contained in:
2015-06-13 08:43:21 +03:00
parent 5b68f01e62
commit 010ad6577f
6 changed files with 39 additions and 28 deletions

View File

@@ -2,18 +2,18 @@
## Auto Generated makefile by CodeLite IDE ## Auto Generated makefile by CodeLite IDE
## any manual changes will be erased ## any manual changes will be erased
## ##
## Debug ## Release
ProjectName :=CrossBench ProjectName :=CrossBench
ConfigurationName :=Debug ConfigurationName :=Release
WorkspacePath := "/data/Sync/SyncProjects/CrossGen" WorkspacePath := "/data/Sync/SyncProjects/CrossGen"
ProjectPath := "/data/Sync/SyncProjects/CrossGen/CrossBench" ProjectPath := "/data/Sync/SyncProjects/CrossGen/CrossBench"
IntermediateDirectory :=./Debug IntermediateDirectory :=./Release
OutDir := $(IntermediateDirectory) OutDir := $(IntermediateDirectory)
CurrentFileName := CurrentFileName :=
CurrentFilePath := CurrentFilePath :=
CurrentFileFullPath := CurrentFileFullPath :=
User :=Aleksey Lobanov User :=Aleksey Lobanov
Date :=12/06/15 Date :=13/06/15
CodeLitePath :="/home/alex/.codelite" CodeLitePath :="/home/alex/.codelite"
LinkerName :=/usr/bin/g++-4.8 LinkerName :=/usr/bin/g++-4.8
SharedObjectLinkerName :=/usr/bin/g++-4.8 -shared -fPIC SharedObjectLinkerName :=/usr/bin/g++-4.8 -shared -fPIC
@@ -28,14 +28,14 @@ LibraryPathSwitch :=-L
PreprocessorSwitch :=-D PreprocessorSwitch :=-D
SourceSwitch :=-c SourceSwitch :=-c
OutputFile :=$(IntermediateDirectory)/$(ProjectName) OutputFile :=$(IntermediateDirectory)/$(ProjectName)
Preprocessors := Preprocessors :=$(PreprocessorSwitch)NDEBUG
ObjectSwitch :=-o ObjectSwitch :=-o
ArchiveOutputSwitch := ArchiveOutputSwitch :=
PreprocessOnlySwitch :=-E PreprocessOnlySwitch :=-E
ObjectsFileList :="CrossBench.txt" ObjectsFileList :="CrossBench.txt"
PCHCompileFlags := PCHCompileFlags :=
MakeDirCommand :=mkdir -p MakeDirCommand :=mkdir -p
LinkOptions := $(shell wx-config --debug=yes --libs --unicode=yes) LinkOptions := -s $(shell wx-config --debug=no --libs --unicode=yes)
IncludePath := $(IncludeSwitch). $(IncludeSwitch)../src IncludePath := $(IncludeSwitch). $(IncludeSwitch)../src
IncludePCH := IncludePCH :=
RcIncludePath := RcIncludePath :=
@@ -50,8 +50,8 @@ LibPath := $(LibraryPathSwitch).
AR := /usr/bin/ar rcu AR := /usr/bin/ar rcu
CXX := /usr/bin/g++-4.8 CXX := /usr/bin/g++-4.8
CC := /usr/bin/gcc-4.8 CC := /usr/bin/gcc-4.8
CXXFLAGS := -std=c++11 -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) $(Preprocessors) CXXFLAGS := -std=c++11 -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors)
CFLAGS := -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) $(Preprocessors) CFLAGS := -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors)
ASFLAGS := ASFLAGS :=
AS := /usr/bin/as AS := /usr/bin/as
@@ -79,7 +79,7 @@ $(OutputFile): $(IntermediateDirectory)/.d $(Objects)
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions) $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
$(IntermediateDirectory)/.d: $(IntermediateDirectory)/.d:
@test -d ./Debug || $(MakeDirCommand) ./Debug @test -d ./Release || $(MakeDirCommand) ./Release
PreBuild: PreBuild:
@@ -101,6 +101,6 @@ $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp
## Clean ## Clean
## ##
clean: clean:
$(RM) -r ./Debug/ $(RM) -r ./Release/

View File

@@ -1 +1 @@
./Debug/main.cpp.o ./Release/main.cpp.o

View File

@@ -20,6 +20,8 @@ static const wxCmdLineEntryDesc cmdLineDesc[] = {
wxCMD_LINE_VAL_STRING }, 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_VAL_NUMBER },
{ wxCMD_LINE_SWITCH, wxT("r"), wxT("rand"), wxT("enables generating random crosswords") ,
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 }
@@ -32,13 +34,17 @@ int main(int argc, char **argv) {
return -1; return -1;
} }
wxCmdLineParser cmd_parser(cmdLineDesc, argc, argv); wxCmdLineParser cmd_parser(cmdLineDesc, argc, argv);
long run_count = 10; long run_count = 10;
wxString grid_path, dict_path; wxString grid_path, dict_path;
bool is_rand = false;
switch ( cmd_parser.Parse() ) { switch ( cmd_parser.Parse() ) {
case -1: case -1:
return 0; return 0;
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"));
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"));
@@ -56,7 +62,12 @@ int main(int argc, char **argv) {
readDict(dict_path, dict); readDict(dict_path, dict);
readGrid(grid_path, grid); readGrid(grid_path, grid);
if ( is_rand )
srand(time(NULL));
for (long i = 0; i < run_count; ++i) { for (long i = 0; i < run_count; ++i) {
if ( !is_rand )
srand(42);
words_out.clear(); words_out.clear();
durs.at(i) = wxGetLocalTimeMillis(); durs.at(i) = wxGetLocalTimeMillis();
generateCross(grid,dict,words_out); generateCross(grid,dict,words_out);
@@ -65,7 +76,7 @@ int main(int argc, char **argv) {
durs.at(i) = wxGetLocalTimeMillis() - durs.at(i); durs.at(i) = wxGetLocalTimeMillis() - durs.at(i);
} }
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; wxLongLong tm_mean = (tm_total + run_count/2) / run_count;
wxPrintf(wxT("Total time = ") + tm_total.ToString() + wxT(" ms.\nMean time = ") wxPrintf(wxT("Total time = ") + tm_total.ToString() + wxT(" ms.\nMean time = ")
+ tm_mean.ToString() + wxT(" ms.\n")); + tm_mean.ToString() + wxT(" ms.\n"));
return 0; return 0;

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Workspace Name="CrossGen" Database=""> <CodeLite_Workspace Name="CrossGen" Database="">
<Project Name="wxCrossGen" Path="wxCrossGen/wxCrossGen.project" Active="Yes"/> <Project Name="wxCrossGen" Path="wxCrossGen/wxCrossGen.project" Active="No"/>
<Project Name="CrossBench" Path="CrossBench/CrossBench.project" Active="No"/> <Project Name="CrossBench" Path="CrossBench/CrossBench.project" Active="Yes"/>
<BuildMatrix> <BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes"> <WorkspaceConfiguration Name="Debug" Selected="yes">
<Project Name="wxCrossGen" ConfigName="Debug"/> <Project Name="wxCrossGen" ConfigName="Debug"/>

View File

@@ -1,8 +1,8 @@
.PHONY: clean All .PHONY: clean All
All: All:
@echo "----------Building project:[ wxCrossGen - Release ]----------" @echo "----------Building project:[ CrossBench - Release ]----------"
@cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" @cd "CrossBench" && $(MAKE) -f "CrossBench.mk"
clean: clean:
@echo "----------Cleaning project:[ wxCrossGen - Release ]----------" @echo "----------Cleaning project:[ CrossBench - Release ]----------"
@cd "wxCrossGen" && $(MAKE) -f "wxCrossGen.mk" clean @cd "CrossBench" && $(MAKE) -f "CrossBench.mk" clean

View File

@@ -2,12 +2,12 @@
## Auto Generated makefile by CodeLite IDE ## Auto Generated makefile by CodeLite IDE
## any manual changes will be erased ## any manual changes will be erased
## ##
## Release ## Debug
ProjectName :=wxCrossGen ProjectName :=wxCrossGen
ConfigurationName :=Release ConfigurationName :=Debug
WorkspacePath := "/data/Sync/SyncProjects/CrossGen" WorkspacePath := "/data/Sync/SyncProjects/CrossGen"
ProjectPath := "/data/Sync/SyncProjects/CrossGen/wxCrossGen" ProjectPath := "/data/Sync/SyncProjects/CrossGen/wxCrossGen"
IntermediateDirectory :=../Release IntermediateDirectory :=./Debug
OutDir := $(IntermediateDirectory) OutDir := $(IntermediateDirectory)
CurrentFileName := CurrentFileName :=
CurrentFilePath := CurrentFilePath :=
@@ -28,14 +28,14 @@ LibraryPathSwitch :=-L
PreprocessorSwitch :=-D PreprocessorSwitch :=-D
SourceSwitch :=-c SourceSwitch :=-c
OutputFile :=$(IntermediateDirectory)/$(ProjectName).out OutputFile :=$(IntermediateDirectory)/$(ProjectName).out
Preprocessors :=$(PreprocessorSwitch)NDEBUG Preprocessors :=
ObjectSwitch :=-o ObjectSwitch :=-o
ArchiveOutputSwitch := ArchiveOutputSwitch :=
PreprocessOnlySwitch :=-E PreprocessOnlySwitch :=-E
ObjectsFileList :="wxCrossGen.txt" ObjectsFileList :="wxCrossGen.txt"
PCHCompileFlags := PCHCompileFlags :=
MakeDirCommand :=mkdir -p MakeDirCommand :=mkdir -p
LinkOptions := -s $(shell wx-config --debug=no --libs --unicode=yes) LinkOptions := $(shell wx-config --debug=yes --libs --unicode=yes)
IncludePath := $(IncludeSwitch). $(IncludeSwitch)../src IncludePath := $(IncludeSwitch). $(IncludeSwitch)../src
IncludePCH := IncludePCH :=
RcIncludePath := RcIncludePath :=
@@ -50,8 +50,8 @@ LibPath := $(LibraryPathSwitch).
AR := /usr/bin/ar rcu AR := /usr/bin/ar rcu
CXX := /usr/bin/g++-4.8 CXX := /usr/bin/g++-4.8
CC := /usr/bin/gcc-4.8 CC := /usr/bin/gcc-4.8
CXXFLAGS := -std=c++11 -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors) CXXFLAGS := -std=c++11 -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) $(Preprocessors)
CFLAGS := -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors) CFLAGS := -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) $(Preprocessors)
ASFLAGS := ASFLAGS :=
AS := /usr/bin/as AS := /usr/bin/as
@@ -79,7 +79,7 @@ $(OutputFile): $(IntermediateDirectory)/.d $(Objects)
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions) $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
$(IntermediateDirectory)/.d: $(IntermediateDirectory)/.d:
@test -d ../Release || $(MakeDirCommand) ../Release @test -d ./Debug || $(MakeDirCommand) ./Debug
PreBuild: PreBuild:
@@ -101,6 +101,6 @@ $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp
## Clean ## Clean
## ##
clean: clean:
$(RM) -r ../Release/ $(RM) -r ./Debug/