Skip to content

Commit eda9e45

Browse files
author
Raghuveer Devulapalli
committed
Improve bench.out formatting
1 parent 6bf257f commit eda9e45

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

benchmarks/main.cpp

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,33 @@
1212
#include <typeinfo>
1313
#include <vector>
1414

15+
template <typename T1,
16+
typename T2,
17+
typename T3,
18+
typename T4,
19+
typename T5,
20+
typename T6,
21+
typename T7>
22+
void printLine(const char fill, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
23+
{
24+
std::cout << std::left << std::setw(3) << std::setfill(fill) << " | ";
25+
std::cout << std::left << std::setw(15) << std::setfill(fill) << t1
26+
<< " | ";
27+
std::cout << std::left << std::setw(13) << std::setfill(fill) << t2
28+
<< " | ";
29+
std::cout << std::left << std::setw(13) << std::setfill(fill) << t3
30+
<< " | ";
31+
std::cout << std::left << std::setw(13) << std::setfill(fill) << t4
32+
<< " | ";
33+
std::cout << std::left << std::setw(13) << std::setfill(fill) << t5
34+
<< " | ";
35+
std::cout << std::left << std::setw(13) << std::setfill(fill) << t6
36+
<< " | ";
37+
std::cout << std::left << std::setw(13) << std::setfill(fill) << t7
38+
<< " | ";
39+
std::cout << std::endl;
40+
}
41+
1542
template <typename T>
1643
void run_bench(const std::string datatype)
1744
{
@@ -43,10 +70,14 @@ void run_bench(const std::string datatype)
4370
return;
4471
}
4572
auto out = bench_sort(arr, 20, 10);
46-
std::cout << datatype << "," << typeid(T).name() << "," << sizeof(T)
47-
<< "," << size << "," << std::get<0>(out) << ","
48-
<< std::get<1>(out) << ","
49-
<< (float)std::get<1>(out) / std::get<0>(out) << std::endl;
73+
printLine(' ',
74+
datatype,
75+
typeid(T).name(),
76+
sizeof(T),
77+
size,
78+
std::get<0>(out),
79+
std::get<1>(out),
80+
(float)std::get<1>(out) / std::get<0>(out));
5081
}
5182
std::cout << std::setprecision(ss);
5283
}
@@ -69,13 +100,19 @@ void bench_all(const std::string datatype)
69100

70101
int main(/*int argc, char *argv[]*/)
71102
{
72-
std::cout
73-
<< "Array type,typeid name, dtype size, array size,avx512 sort,std "
74-
"sort,avx-512 speed up"
75-
<< std::endl;
103+
printLine(' ',
104+
"array type",
105+
"typeid name",
106+
"dtype size",
107+
"array size",
108+
"avx512 sort",
109+
"std sort",
110+
"speed up");
111+
printLine('-', "", "", "", "", "", "", "");
76112
bench_all("uniform random");
77113
bench_all("reverse");
78114
bench_all("ordered");
79115
bench_all("limitedrange");
116+
printLine('-', "", "", "", "", "", "", "");
80117
return 0;
81118
}

0 commit comments

Comments
 (0)