added feature to use profilers with algorithms more easily

This commit is contained in:
Richard Thier 2022-08-16 18:37:13 +02:00
parent 36ea38940b
commit 4bed99751f

View File

@ -392,10 +392,36 @@
free(pd);
}
// to measure / profile a single variant
void measure_single(int n) {
for (auto inputtype : inputtypes) {
printf("%10s", inputtype.c_str());
fflush(stdout);
std::vector<uint32_t> v(n);
v = geninput(inputtype, n);
measure(inputtype, "sp", [&] { spsort(&v[0], v.size()); });
for (auto r : results) printf("%9.3fs", r.second);
puts("");
}
puts("");
printf("%10s", "worst");
for (auto w : worst) printf("%9.3fs", w.second);
puts("");
printf("%10s", "");
for (auto w : worst) printf("%10s", w.first.c_str());
puts("");
}
int main(void) {
int n = 100000000;
//int n = 10000000;
//int n = 64;
// Uncomment this for profiling and alg!
measure_single(n);
return 0;
for (auto inputtype : inputtypes) {
printf("%10s", inputtype.c_str());
fflush(stdout);