forked from travisdowns/uarch-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark-group.cpp
52 lines (39 loc) · 1.24 KB
/
benchmark-group.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* benchmark-group.cpp
*/
#include <cassert>
#include "benchmark.hpp"
#include "table.hpp"
#include "simple-timer.hpp"
using namespace std;
using namespace table;
void BenchmarkGroup::runIf(Context &c, const predicate_t& predicate) {
SimpleTimer timer;
bool header = false;
for (auto& b : benches_) {
if (predicate(b)) {
if (!header) {
c.out() << std::endl << "** Running group " << getId() << " : " << getDescription() << " **" << std::endl;
printGroupHeader(c);
header = true;
}
b->runAndPrint(c);
}
}
if (header) {
c.out() << "Finished in " << timer.elapsed<std::chrono::milliseconds>() << " ms (" << getId() << ")" << endl;
}
}
void BenchmarkGroup::printBenches(std::ostream& out) const {
Table t;
t.colInfo(0).justify = ColInfo::LEFT;
t.newRow().add("ID").add("Description").add("Tags").add("ISA Features");
for (auto& bench : getBenches()) {
t.newRow()
.add(bench->getPath())
.add(bench->getDescription())
.add(container_to_string(bench->getTags()))
.add(container_to_string(bench->getFeatures()));
}
out << t.str();
}