[Compbench-devel] CompBenchmarks++/compbenchmarks-plan cloptions.cpp, 1.8, 1.9
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-08-21 19:45:43
|
Update of /cvsroot/compbench/CompBenchmarks++/compbenchmarks-plan In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv31469 Modified Files: cloptions.cpp Log Message: Configurable output directory. Results can be archived. Index: cloptions.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/compbenchmarks-plan/cloptions.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** cloptions.cpp 2 Aug 2007 19:12:32 -0000 1.8 --- cloptions.cpp 21 Aug 2007 19:45:41 -0000 1.9 *************** *** 37,41 **** ActionRegisterOption, ActionUnregisterOption, ActionListOption, ActionRegisterBenchmark, ActionUnregisterBenchmark, ActionListBenchmark, ! ActionRun } OptAction; --- 37,41 ---- ActionRegisterOption, ActionUnregisterOption, ActionListOption, ActionRegisterBenchmark, ActionUnregisterBenchmark, ActionListBenchmark, ! ActionRun, ActionArchive } OptAction; *************** *** 53,56 **** --- 53,58 ---- << "Plan management :" << std::endl << " --plan-register <file> [--default] : create file[.xml] plan." << std::endl + << " --output-directory <directory> : defines the directory holding results" << std::endl + << " for new plan." << std::endl << " --plan-unregister <file> : remove a plan (including file)." << std::endl << " --plan-use <fil> : explicitly use given plan." << std::endl *************** *** 80,83 **** --- 82,86 ---- << "Benchmarking : " << std::endl << " --run : start/resume benchmark." << std::endl + << " --archive <file.tar.gz> : archive results." << std::endl << std::endl; } *************** *** 184,187 **** --- 187,219 ---- } + int archiveResults(CBM::Plan *P, std::string fn) + { + std::string cmd = cbmSystem->Program("TAR"); + std::string output; + + cmd+=" c "; + cmd+=P->getOutputDirectory(); + cmd+="/* | "; + cmd+=cbmSystem->Program("GZIP"); + cmd+=" -9 > "; + cmd+=fn; + + cmd+=" && "; + cmd+=cbmSystem->Program("RM"); + cmd+=" -rf "; + cmd+=P->getOutputDirectory(); + + std::cout << "Archiving " << P->getOutputDirectory() << " in " + << fn << ", and removing directory... "; + + if (!cbmSystem->exec(cmd, output)) { + std::cout << "done."; + } else { + std::cout << output; + } + std::cout << std::endl; + return(0); + } + int cbmPlanOptionsParse(int argc, char *argv[]) { *************** *** 200,203 **** --- 232,237 ---- std::string option; std::string benchmarkName; + std::string outputDirectoryName; + std::string archiveName; CBM::Plan *P = 0; *************** *** 248,251 **** --- 282,289 ---- {"run", no_argument, 0, 8001}, + {"output-directory", required_argument, 0, 9001}, + + {"archive", required_argument, 0, 10001}, + { 0, 0, 0, 0 } }; *************** *** 365,368 **** --- 403,413 ---- action=ActionRun; break; + case 9001: + outputDirectoryName=optarg; + break; + case 10001: + action=ActionArchive; + archiveName=optarg; + break; default: case '?': *************** *** 382,385 **** --- 427,436 ---- } P = new CBM::Plan; + + if (outputDirectoryName=="") { + std::cerr << "Please, specify an output directory name (see --output-directory)" << std::endl; + break; + } + P->setOutputDirectory(outputDirectoryName); storePlan(P, planFileName); *************** *** 924,931 **** cbmUI->msgPlanRun("plan"); while (P->nextIteration(0)); ! delete(P); break; default: printf("?\n"); --- 975,996 ---- cbmUI->msgPlanRun("plan"); while (P->nextIteration(0)); ! std::cout << "Results and settings (*.xml) in directory " << P->getOutputDirectory() << " ." << std::endl; ! std::cout << "You can now launch compbenchmarks-plan with --store <filename.tar.gz> to keep results." << std::endl; delete(P); break; + case ActionArchive: + if (!getPlanFileName(planFileName)) + break; + + P=restorePlan(planFileName); + + if (!P) + break; + + archiveResults(P, archiveName); + + delete(P); + break; default: printf("?\n"); |