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) {}
|
BasicPruner(bool use_instr1 = false) : use_instr1(use_instr1) {}
|
||||||
virtual std::string method_name() { return std::string("basic") + (use_instr1 ? "-left" : ""); }
|
virtual std::string method_name() { return std::string("basic") + (use_instr1 ? "-left" : ""); }
|
||||||
virtual bool prune_all();
|
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
|
#endif
|
||||||
|
|||||||
@ -24,6 +24,11 @@ public:
|
|||||||
virtual bool commandline_init();
|
virtual bool commandline_init();
|
||||||
virtual bool prune_all();
|
virtual bool prune_all();
|
||||||
|
|
||||||
|
void getAliases(std::deque<std::string> *aliases) {
|
||||||
|
aliases->push_back("FESamplingPruner");
|
||||||
|
aliases->push_back("sampling");
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool sampling_prune(const fail::Database::Variant& variant);
|
bool sampling_prune(const fail::Database::Variant& variant);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,8 +4,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "util/Database.hpp"
|
#include "util/Database.hpp"
|
||||||
|
#include "util/AliasedRegisterable.hpp"
|
||||||
|
|
||||||
class Pruner {
|
class Pruner : public fail::AliasedRegisterable {
|
||||||
protected:
|
protected:
|
||||||
int m_method_id;
|
int m_method_id;
|
||||||
fail::Database *db;
|
fail::Database *db;
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "util/CommandLine.hpp"
|
#include "util/CommandLine.hpp"
|
||||||
#include "util/Logger.hpp"
|
#include "util/Logger.hpp"
|
||||||
|
#include "util/AliasedRegistry.hpp"
|
||||||
|
|
||||||
static fail::Logger LOG("prune-trace", true);
|
static fail::Logger LOG("prune-trace", true);
|
||||||
|
|
||||||
using namespace fail;
|
using namespace fail;
|
||||||
@ -16,6 +18,17 @@ using std::endl;
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
std::string username, hostname, database;
|
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
|
// Manually fill the command line option parser
|
||||||
CommandLine &cmd = CommandLine::Inst();
|
CommandLine &cmd = CommandLine::Inst();
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
@ -39,9 +52,9 @@ int main(int argc, char *argv[]) {
|
|||||||
CommandLine::option_handle BENCHMARK_EXCLUDE =
|
CommandLine::option_handle BENCHMARK_EXCLUDE =
|
||||||
cmd.addOption("", "benchmark-exclude", Arg::Required,
|
cmd.addOption("", "benchmark-exclude", Arg::Required,
|
||||||
"--benchmark-exclude \tBenchmark to exclude (default: UNSET; use % and _ as wildcard characters; may be used more than once)");
|
"--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 =
|
CommandLine::option_handle PRUNER =
|
||||||
cmd.addOption("p", "prune-method", Arg::Required,
|
cmd.addOption("p", "prune-method", Arg::Required, pruner_help);
|
||||||
"-p/--prune-method \tWhich import method to use (default: basic)");
|
|
||||||
CommandLine::option_handle NO_DELETE =
|
CommandLine::option_handle NO_DELETE =
|
||||||
cmd.addOption("", "no-delete", Arg::None,
|
cmd.addOption("", "no-delete", Arg::None,
|
||||||
"--no-delete \tAssume there are no DB entries for this variant/benchmark, don't issue a DELETE");
|
"--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;
|
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]) {
|
if (cmd[PRUNER]) {
|
||||||
std::string imp(cmd[PRUNER].first()->arg);
|
std::string imp(cmd[PRUNER].first()->arg);
|
||||||
if (imp == "BasicPruner" || imp == "basic") {
|
if (imp == "BasicPruner" || imp == "basic") {
|
||||||
|
|||||||
Reference in New Issue
Block a user