From b2b53380f4a0d95bb7f8a4682915574ec419e848 Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Sat, 6 Dec 2014 00:19:17 +0100 Subject: [PATCH] prune-trace: add switch to disable sample weighting In the sampling step, the --no-weighting switch disables the equivalence-class weighting by using a weight of one instead of the equivalence-class size. This is usually not a good idea, and should only be used for demonstration purposes, or if the fault model requires weight-less sampling. Change-Id: Id903d1924c6ecbcd217815aa5ce9271560130071 --- tools/prune-trace/FESamplingPruner.cc | 11 +++++++++-- tools/prune-trace/FESamplingPruner.hpp | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/prune-trace/FESamplingPruner.cc b/tools/prune-trace/FESamplingPruner.cc index c0740de8..431adb86 100644 --- a/tools/prune-trace/FESamplingPruner.cc +++ b/tools/prune-trace/FESamplingPruner.cc @@ -32,6 +32,9 @@ bool FESamplingPruner::commandline_init() USE_KNOWN_RESULTS = cmd.addOption("", "use-known-results", Arg::None, "--use-known-results \tReuse known results from a campaign with the 'basic' pruner " "(abuses the DB layout to a certain degree, use with caution)"); + NO_WEIGHTING = cmd.addOption("", "no-weighting", Arg::None, + "--no-weighting \tDisable weighted sampling (weight = 1 for all ECs) " + "(don't do this unless you know what you're doing)"); return true; } @@ -48,6 +51,10 @@ bool FESamplingPruner::prune_all() m_use_known_results = true; } + if (cmd[NO_WEIGHTING]) { + m_weighting = false; + } + // for each variant: for (std::vector::const_iterator it = m_variants.begin(); it != m_variants.end(); ++it) { @@ -105,7 +112,7 @@ bool FESamplingPruner::sampling_prune(const fail::Database::Variant& variant) p.instr2 = strtoul(row[0], 0, 10); p.instr2_absolute = strtoul(row[1], 0, 10); p.data_address = strtoul(row[2], 0, 10); - p.duration = strtoull(row[3], 0, 10); + p.duration = m_weighting ? strtoull(row[3], 0, 10) : 1; pop.add(p); ++pilotcount; } @@ -132,7 +139,7 @@ bool FESamplingPruner::sampling_prune(const fail::Database::Variant& variant) p.id = strtoul(row[0], 0, 10); p.instr2 = strtoul(row[1], 0, 10); p.data_address = strtoul(row[2], 0, 10); - p.duration = strtoull(row[3], 0, 10); + p.duration = m_weighting ? strtoull(row[3], 0, 10) : 1; pop.add(p); ++pilotcount; } diff --git a/tools/prune-trace/FESamplingPruner.hpp b/tools/prune-trace/FESamplingPruner.hpp index 7c71c530..860504ab 100644 --- a/tools/prune-trace/FESamplingPruner.hpp +++ b/tools/prune-trace/FESamplingPruner.hpp @@ -16,12 +16,13 @@ class FESamplingPruner : public Pruner { fail::CommandLine::option_handle SAMPLESIZE; fail::CommandLine::option_handle USE_KNOWN_RESULTS; + fail::CommandLine::option_handle NO_WEIGHTING; unsigned m_samplesize; - bool m_use_known_results; + bool m_use_known_results, m_weighting; public: - FESamplingPruner() : m_samplesize(0), m_use_known_results(false) { } + FESamplingPruner() : m_samplesize(0), m_use_known_results(false), m_weighting(true) { } virtual std::string method_name() { return "FESampling"; } virtual bool commandline_init(); virtual bool prune_all();