// etabench // Copyright (C) 2022 xaizek <xaizek@posteo.net> // // This file is part of etabench. // // etabench is free software: you can redistribute it and/or modify // it under the terms of version 3 of the GNU General Public License // as published by the Free Software Foundation. // // etabench is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with etabench. If not, see <https://www.gnu.org/licenses/>. #include "Args.hpp" #include <cstdlib> #include <stdexcept> #include <tclap/CmdLine.h> Args::Args(int argc, char *argv[]) { TCLAP::CmdLine cmd("I/O ETA benchmark.", ' ', "0.1", /*help=*/false); TCLAP::ValueArg<int> totalArg("", "total", "Simulated transfer total.", /*req=*/false, 1000, "integer", cmd); TCLAP::ValueArg<std::string> plotArg("", "plot", "Use gnuplot to make graphs per " "profile in <dir>.", /*req=*/false, "", "dir", cmd); TCLAP::ValueArg<std::string> montageArg("", "montage", "Use ImageMagick to montage plots " "in <file>.", /*req=*/false, "", "file", cmd); TCLAP::SwitchArg listAlgsArg("", "list-algs", "List available algorithms.", cmd, /*def=*/false); TCLAP::SwitchArg listProfsArg("", "list-profs", "List available profiles.", cmd, /*def=*/false); TCLAP::ValueArg<std::string> algsArg("", "algs", "List of algorithms to benchmark.", /*req=*/false, /*def=*/std::string(), "list", cmd); TCLAP::ValueArg<std::string> profsArg("", "profs", "List of profiles to benchmark.", /*req=*/false, /*def=*/std::string(), "list", cmd); TCLAP::SwitchArg verboseArg("", "verbose", "Display verbose output.", cmd, /*def=*/false); TCLAP::SwitchArg help("h", "help", "Displays usage information and exits.", cmd, /*def=*/false); TCLAP::SwitchArg vers("v", "version", "Displays version information and exits.", cmd, /*def=*/false); cmd.parse(argc, argv); if (help) { TCLAP::StdOutput stdOutput; stdOutput.usage(cmd); std::exit(0); } if (vers) { TCLAP::StdOutput stdOutput; stdOutput.version(cmd); std::exit(0); } total = totalArg; plotDir = plotArg; montageFile = montageArg; verbose = verboseArg; listAlgs = listAlgsArg; listProfs = listProfsArg; algs = algsArg; profs = profsArg; // The value is limited because of hard-coded values in profiles. Deriving // them or correcting code can remove the limit. The latter option sounds // better. if (total < 50) { throw std::runtime_error("--total must be at least 50."); } }