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
## any manual changes will be erased
##
## Debug
## Release
ProjectName :=CrossBench
ConfigurationName :=Debug
ConfigurationName :=Release
WorkspacePath := "/data/Sync/SyncProjects/CrossGen"
ProjectPath := "/data/Sync/SyncProjects/CrossGen/CrossBench"
IntermediateDirectory :=./Debug
IntermediateDirectory :=./Release
OutDir := $(IntermediateDirectory)
CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=Aleksey Lobanov
Date :=12/06/15
Date :=13/06/15
CodeLitePath :="/home/alex/.codelite"
LinkerName :=/usr/bin/g++-4.8
SharedObjectLinkerName :=/usr/bin/g++-4.8 -shared -fPIC
@@ -28,14 +28,14 @@ LibraryPathSwitch :=-L
PreprocessorSwitch :=-D
SourceSwitch :=-c
OutputFile :=$(IntermediateDirectory)/$(ProjectName)
Preprocessors :=
Preprocessors :=$(PreprocessorSwitch)NDEBUG
ObjectSwitch :=-o
ArchiveOutputSwitch :=
PreprocessOnlySwitch :=-E
ObjectsFileList :="CrossBench.txt"
PCHCompileFlags :=
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
IncludePCH :=
RcIncludePath :=
@@ -50,8 +50,8 @@ LibPath := $(LibraryPathSwitch).
AR := /usr/bin/ar rcu
CXX := /usr/bin/g++-4.8
CC := /usr/bin/gcc-4.8
CXXFLAGS := -std=c++11 -g -O0 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=yes) $(Preprocessors)
CFLAGS := -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 := -O2 -Wall $(shell wx-config --cxxflags --unicode=yes --debug=no) $(Preprocessors)
ASFLAGS :=
AS := /usr/bin/as
@@ -79,7 +79,7 @@ $(OutputFile): $(IntermediateDirectory)/.d $(Objects)
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)
$(IntermediateDirectory)/.d:
@test -d ./Debug || $(MakeDirCommand) ./Debug
@test -d ./Release || $(MakeDirCommand) ./Release
PreBuild:
@@ -101,6 +101,6 @@ $(IntermediateDirectory)/main.cpp$(PreprocessSuffix): main.cpp
## 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_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_VAL_NONE },
{ wxCMD_LINE_SWITCH, wxT("h"), wxT("help"), wxT("show this help message"),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_NONE }
@@ -32,13 +34,17 @@ int main(int argc, char **argv) {
return -1;
}
wxCmdLineParser cmd_parser(cmdLineDesc, argc, argv);
long run_count = 10;
wxString grid_path, dict_path;
bool is_rand = 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);
wxLogDebug(wxT("grid_path = ") + grid_path + wxT("\n"));
@@ -55,8 +61,13 @@ int main(int argc, char **argv) {
readDict(dict_path, dict);
readGrid(grid_path, grid);
if ( is_rand )
srand(time(NULL));
for (long i = 0; i < run_count; ++i) {
if ( !is_rand )
srand(42);
words_out.clear();
durs.at(i) = wxGetLocalTimeMillis();
generateCross(grid,dict,words_out);
@@ -65,7 +76,7 @@ int main(int argc, char **argv) {
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;
wxLongLong tm_mean = (tm_total + run_count/2) / run_count;
wxPrintf(wxT("Total time = ") + tm_total.ToString() + wxT(" ms.\nMean time = ")
+ tm_mean.ToString() + wxT(" ms.\n"));
return 0;

View File

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

View File

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

View File

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