aboutsummaryrefslogtreecommitdiff
path: root/framework/Framework.cpp
diff options
context:
space:
mode:
authorMoritz Pflanzer <moritz.pflanzer@arm.com>2017-07-05 11:02:23 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 14:15:39 +0100
commita4f711b0fa38aecf0aacdbf61acf86bd25aa674a (patch)
tree6efb1362fc8ebb50f43095484b6cc42e8394e7f6 /framework/Framework.cpp
parent69e44dc073bae7f7f54923d306a52d809b1334d5 (diff)
downloadComputeLibrary-a4f711b0fa38aecf0aacdbf61acf86bd25aa674a.tar.gz
COMPMID-415: New framework - instruments [3/5]
Change-Id: I834c2693566185ce8d8d024fb5db79610a18c8c1 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/79757 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'framework/Framework.cpp')
-rw-r--r--framework/Framework.cpp52
1 files changed, 50 insertions, 2 deletions
diff --git a/framework/Framework.cpp b/framework/Framework.cpp
index b54c0c75b6..692e17cb91 100644
--- a/framework/Framework.cpp
+++ b/framework/Framework.cpp
@@ -37,6 +37,27 @@ namespace test
{
namespace framework
{
+Framework::Framework()
+{
+ _available_instruments.emplace(InstrumentType::WALL_CLOCK_TIMER, Instrument::make_instrument<WallClockTimer>);
+#ifdef PMU_ENABLED
+ _available_instruments.emplace(InstrumentType::PMU_CYCLE_COUNTER, Instrument::make_instrument<CycleCounter>);
+ _available_instruments.emplace(InstrumentType::PMU_INSTRUCTION_COUNTER, Instrument::make_instrument<InstructionCounter>);
+#endif /* PMU_ENABLED */
+}
+
+std::set<InstrumentType> Framework::available_instruments() const
+{
+ std::set<InstrumentType> types;
+
+ for(const auto &instrument : _available_instruments)
+ {
+ types.emplace(instrument.first);
+ }
+
+ return types;
+}
+
std::tuple<int, int, int> Framework::count_test_results() const
{
int passed = 0;
@@ -71,11 +92,18 @@ Framework &Framework::get()
return instance;
}
-void Framework::init(int num_iterations, const std::string &name_filter, const std::string &id_filter)
+void Framework::init(const std::vector<InstrumentType> &instruments, int num_iterations, const std::string &name_filter, const std::string &id_filter)
{
_test_name_filter = std::regex{ name_filter };
_test_id_filter = std::regex{ id_filter };
_num_iterations = num_iterations;
+
+ _instruments = InstrumentType::NONE;
+
+ for(const auto &instrument : instruments)
+ {
+ _instruments |= instrument;
+ }
}
std::string Framework::current_suite_name() const
@@ -144,6 +172,7 @@ void Framework::run_test(TestCaseFactory &test_factory)
log_test_start(test_case_name);
+ Profiler profiler = get_profiler();
TestResult result;
try
@@ -156,7 +185,9 @@ void Framework::run_test(TestCaseFactory &test_factory)
for(int i = 0; i < _num_iterations; ++i)
{
+ profiler.start();
test_case->do_run();
+ profiler.stop();
}
test_case->do_teardown();
@@ -213,6 +244,8 @@ void Framework::run_test(TestCaseFactory &test_factory)
}
}
+ result.measurements = profiler.measurements();
+
set_test_result(test_case_name, result);
log_test_end(test_case_name);
}
@@ -260,7 +293,22 @@ bool Framework::run()
void Framework::set_test_result(std::string test_case_name, TestResult result)
{
- _test_results.emplace(std::move(test_case_name), result);
+ _test_results.emplace(std::move(test_case_name), std::move(result));
+}
+
+Profiler Framework::get_profiler() const
+{
+ Profiler profiler;
+
+ for(const auto &instrument : _available_instruments)
+ {
+ if((instrument.first & _instruments) != InstrumentType::NONE)
+ {
+ profiler.add(instrument.second());
+ }
+ }
+
+ return profiler;
}
std::vector<Framework::TestId> Framework::test_ids() const