[Compbench-devel] CompBenchmarks++/compbenchmarks-plan cloptions.cpp, 1.3, 1.4
Brought to you by:
xfred
|
From: Frederic T. <xf...@us...> - 2007-05-30 19:27:51
|
Update of /cvsroot/compbench/CompBenchmarks++/compbenchmarks-plan In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3214 Modified Files: cloptions.cpp Log Message: CBM::Benchmark instances handling. Index: cloptions.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/compbenchmarks-plan/cloptions.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cloptions.cpp 30 May 2007 17:08:49 -0000 1.3 --- cloptions.cpp 30 May 2007 19:27:46 -0000 1.4 *************** *** 13,16 **** --- 13,17 ---- #include <Compiler/Compiler.h> #include <Compiler/Compiler-OptionSet.h> + #include <Benchmark/Benchmark.h> #include <UI/UI.h> *************** *** 32,36 **** ActionRegisterCompiler, ActionUnregisterCompiler, ActionListCompiler, ActionRegisterOptionset, ActionUnregisterOptionset, ActionListOptionset, ! ActionRegisterOptions, ActionUnregisterOptions, ActionListOptions } OptAction; --- 33,38 ---- ActionRegisterCompiler, ActionUnregisterCompiler, ActionListCompiler, ActionRegisterOptionset, ActionUnregisterOptionset, ActionListOptionset, ! ActionRegisterOptions, ActionUnregisterOptions, ActionListOptions, ! ActionRegisterBenchmark, ActionUnregisterBenchmark, ActionListBenchmark } OptAction; *************** *** 45,49 **** void cbmOptionsHelp(void) { ! std::cout << "Usage: compbenchmarks-core [OPTIONS]" << std::endl << "Plan management :" << std::endl << " --plan-register <file> [--default] : Create file[.xml] plan." << std::endl --- 47,51 ---- void cbmOptionsHelp(void) { ! std::cout << "Usage: compbenchmarks-plan [OPTIONS]" << std::endl << "Plan management :" << std::endl << " --plan-register <file> [--default] : Create file[.xml] plan." << std::endl *************** *** 135,138 **** --- 137,150 ---- } + CBM::Benchmark *getBenchmark(std::string id) + { + CBM::Benchmark *r = cbmSystem->Benchmark(id); + + if (!r) { + std::cerr << "No valid benchmark provided. See compbenchmarks-core -qib." << std::endl; + } + return(r); + } + int cbmPlanOptionsParse(int argc, char *argv[]) { *************** *** 149,159 **** std::string optionsName; std::string options; ! CBM::Plan *P = 0; ! CBM::PlanBatch *B = 0; CBM::CompilerSelector *CS = 0; CBM::Compiler *C = 0; CBM::CompilerOptionSet *OS = 0; CBM::CompilerOptions *O = 0; int i, n; --- 161,173 ---- std::string optionsName; std::string options; + std::string benchmarkName; ! CBM::Plan *P = 0; ! CBM::PlanBatch *B = 0; CBM::CompilerSelector *CS = 0; CBM::Compiler *C = 0; CBM::CompilerOptionSet *OS = 0; CBM::CompilerOptions *O = 0; + CBM::Benchmark *BM = 0; int i, n; *************** *** 186,189 **** --- 200,207 ---- {"options-list", no_argument, 0, 5003}, + {"benchmark-register", required_argument, 0, 6001}, + {"benchmark-unregister", required_argument, 0, 6002}, + {"benchmark-list", no_argument, 0, 6003}, + { 0, 0, 0, 0 } }; *************** *** 281,284 **** --- 299,313 ---- action=ActionListOptions; break; + case 6001: + action=ActionRegisterBenchmark; + benchmarkName=optarg; + break; + case 6002: + action=ActionUnregisterBenchmark; + benchmarkName=optarg; + break; + case 6003: + action=ActionListBenchmark; + break; default: case '?': *************** *** 581,585 **** delete(P); break; - case ActionRegisterOptions: if (!getPlanFileName(planFileName)) --- 610,613 ---- *************** *** 687,690 **** --- 715,818 ---- break; + case ActionRegisterBenchmark: + if (!getPlanFileName(planFileName)) + break; + + B=restoreBatch(&P, + planFileName, + batchName); + + if (!P) + break; + + if (!B) { + delete(P); + break; + } + + BM=getBenchmark(benchmarkName); + if (!BM) + break; + + if (B->add(BM)) { + storePlan(P, planFileName); + if (!parseExitValue) { + std::cout << BM->Name() << " added in " << B->Id() << std::endl; + } else { + std::cerr << BM->Name() << " can't be added." << std::endl; + } + } else { + std::cerr << benchmarkName << " can't be added; see ./compbenchmarks-core -qib" << std::endl; + std::cerr << "Possible causes are either that " << BM->Name() << " is already present" + << "in that plan or not fully installed." << std::endl; + } + delete(BM); + delete(P); + break; + + case ActionUnregisterBenchmark: + if (!getPlanFileName(planFileName)) + break; + + B=restoreBatch(&P, + planFileName, + batchName); + + if (!P) + break; + + if (!B) { + delete(P); + break; + } + + BM=getBenchmark(benchmarkName); + if (!BM) + break; + + if (B->remove(BM)) { + storePlan(P, planFileName); + if (!parseExitValue) { + std::cout << BM->Name() << " removed from " << B->Id() << std::endl; + } else { + std::cerr << BM->Name() << " can't be removed." << std::endl; + } + } else { + std::cerr << benchmarkName << " can't be removed; see ./compbenchmarks-core -qib" << std::endl; + } + delete(BM); + delete(P); + break; + + + case ActionListBenchmark: + if (!getPlanFileName(planFileName)) + break; + + B=restoreBatch(&P, + planFileName, + batchName); + + if (!P) + break; + + if (!B) { + delete(P); + break; + } + + n=B->benchmarkNumber(); + if (!n) { + std::cout << "No benchmark registered." << std::endl; + } else { + printf("%d benchmark(s) found :\n", n); + + for(i=0; i<n; i++) { + BM=B->getBenchmark(i); + std::cout << " * " << BM->Name() << std::endl; + } + } + delete(P); + break; default: printf("?\n"); |