added feature to use profilers with algorithms more easily
This commit is contained in:
parent
36ea38940b
commit
4bed99751f
26
ypsu.cpp
26
ypsu.cpp
@ -392,10 +392,36 @@
|
|||||||
free(pd);
|
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 main(void) {
|
||||||
int n = 100000000;
|
int n = 100000000;
|
||||||
//int n = 10000000;
|
//int n = 10000000;
|
||||||
//int n = 64;
|
//int n = 64;
|
||||||
|
|
||||||
|
// Uncomment this for profiling and alg!
|
||||||
|
measure_single(n);
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (auto inputtype : inputtypes) {
|
for (auto inputtype : inputtypes) {
|
||||||
printf("%10s", inputtype.c_str());
|
printf("%10s", inputtype.c_str());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user