prune-trace: list available pruners
By using the AliasedRegistry, "prune-trace --help" (and "prune-trace -p '?'") now lists all available Pruners to the user. Change-Id: Ib5e3d00aabc37e6d48d804d2d709812af3f7efb2
This commit is contained in:
@ -9,6 +9,20 @@ public:
|
||||
BasicPruner(bool use_instr1 = false) : use_instr1(use_instr1) {}
|
||||
virtual std::string method_name() { return std::string("basic") + (use_instr1 ? "-left" : ""); }
|
||||
virtual bool prune_all();
|
||||
|
||||
void getAliases(std::deque<std::string> *aliases) {
|
||||
aliases->push_back("BasicPruner");
|
||||
aliases->push_back("basic");
|
||||
}
|
||||
};
|
||||
|
||||
class BasicPrunerLeft : public BasicPruner {
|
||||
public:
|
||||
BasicPrunerLeft() : BasicPruner(true) {}
|
||||
void getAliases(std::deque<std::string> *aliases) {
|
||||
aliases->push_back("BasicPrunerLeft");
|
||||
aliases->push_back("basic-left");
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -24,6 +24,11 @@ public:
|
||||
virtual bool commandline_init();
|
||||
virtual bool prune_all();
|
||||
|
||||
void getAliases(std::deque<std::string> *aliases) {
|
||||
aliases->push_back("FESamplingPruner");
|
||||
aliases->push_back("sampling");
|
||||
}
|
||||
|
||||
private:
|
||||
bool sampling_prune(const fail::Database::Variant& variant);
|
||||
};
|
||||
|
||||
@ -4,8 +4,9 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "util/Database.hpp"
|
||||
#include "util/AliasedRegisterable.hpp"
|
||||
|
||||
class Pruner {
|
||||
class Pruner : public fail::AliasedRegisterable {
|
||||
protected:
|
||||
int m_method_id;
|
||||
fail::Database *db;
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
|
||||
#include "util/CommandLine.hpp"
|
||||
#include "util/Logger.hpp"
|
||||
#include "util/AliasedRegistry.hpp"
|
||||
|
||||
static fail::Logger LOG("prune-trace", true);
|
||||
|
||||
using namespace fail;
|
||||
@ -16,6 +18,17 @@ using std::endl;
|
||||
int main(int argc, char *argv[]) {
|
||||
std::string username, hostname, database;
|
||||
|
||||
// register possible Pruners
|
||||
AliasedRegistry registry;
|
||||
BasicPruner basicpruner;
|
||||
registry.add(&basicpruner);
|
||||
BasicPrunerLeft basicprunerleft;
|
||||
registry.add(&basicprunerleft);
|
||||
FESamplingPruner fesamplingpruner;
|
||||
registry.add(&fesamplingpruner);
|
||||
|
||||
std::string pruners = registry.getPrimeAliasesCSV();
|
||||
|
||||
// Manually fill the command line option parser
|
||||
CommandLine &cmd = CommandLine::Inst();
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
@ -39,9 +52,9 @@ int main(int argc, char *argv[]) {
|
||||
CommandLine::option_handle BENCHMARK_EXCLUDE =
|
||||
cmd.addOption("", "benchmark-exclude", Arg::Required,
|
||||
"--benchmark-exclude \tBenchmark to exclude (default: UNSET; use % and _ as wildcard characters; may be used more than once)");
|
||||
std::string pruner_help = "-p/--prune-method \tWhich pruning method to use (default: basic); available pruning methods: " + pruners;
|
||||
CommandLine::option_handle PRUNER =
|
||||
cmd.addOption("p", "prune-method", Arg::Required,
|
||||
"-p/--prune-method \tWhich import method to use (default: basic)");
|
||||
cmd.addOption("p", "prune-method", Arg::Required, pruner_help);
|
||||
CommandLine::option_handle NO_DELETE =
|
||||
cmd.addOption("", "no-delete", Arg::None,
|
||||
"--no-delete \tAssume there are no DB entries for this variant/benchmark, don't issue a DELETE");
|
||||
@ -55,6 +68,20 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
Pruner *pruner;
|
||||
std::string pruner_name = "BasicPruner";
|
||||
if (cmd[PRUNER]) {
|
||||
pruner_name = cmd[PRUNER].first()->arg;
|
||||
}
|
||||
|
||||
// try and get the according pruner object; die on failure
|
||||
if ((pruner = (Pruner *)registry.get(pruner_name)) == 0) {
|
||||
if (pruner_name != "?" ) {
|
||||
std::cerr << "Unknown import method: " << pruner_name << std::endl;
|
||||
}
|
||||
std::cerr << "Available import methods: " << pruners << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (cmd[PRUNER]) {
|
||||
std::string imp(cmd[PRUNER].first()->arg);
|
||||
if (imp == "BasicPruner" || imp == "basic") {
|
||||
|
||||
Reference in New Issue
Block a user