diff options
| author | mzuenni <michi.zuendorf@gmail.com> | 2025-07-10 17:40:18 +0200 |
|---|---|---|
| committer | mzuenni <michi.zuendorf@gmail.com> | 2025-07-10 17:40:18 +0200 |
| commit | 630a5bdf06d59b8340fb4bfc0e692cbcf094026a (patch) | |
| tree | adee732c8d2cdcb46e5f400611c370b4c2ec1947 /test/graph/bitonicTSPsimple.cpp.todo | |
| parent | 609d5a3bf490cfa151b40e60cb62c8ff751bbe56 (diff) | |
run with sanitizer
Diffstat (limited to 'test/graph/bitonicTSPsimple.cpp.todo')
| -rw-r--r-- | test/graph/bitonicTSPsimple.cpp.todo | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/graph/bitonicTSPsimple.cpp.todo b/test/graph/bitonicTSPsimple.cpp.todo new file mode 100644 index 0000000..7e0a80b --- /dev/null +++ b/test/graph/bitonicTSPsimple.cpp.todo @@ -0,0 +1,49 @@ +#include "../util.h" +namespace got { +#include <graph/bitonicTSPsimple.cpp> +} +namespace expected { +#include <graph/bitonicTSP.cpp> +} + +void stress_test() { + ll queries = 0; + for (int tries = 0; tries < 200'000; tries++) { + int n = Random::integer<int>(2, 30); + + vector<vector<double>> dist(n); + for (auto& v : dist) v = Random::reals<double>(n, 0, 1e18); + + got::dist = dist; + expected::dist = dist; + + auto got = got::bitonicTSP(); + auto expected = expected::bitonicTSP(); + + if (got != expected) cerr << "error" << FAIL; + queries += n; + } + cerr << "tested random queries: " << queries << endl; +} + +//this is an easy graph... +constexpr int N = 2'000; +void performance_test() { + timer t; + got::dist = vector<vector<double>>(N); + for (auto& v : got::dist) v = Random::reals<double>(N, 0, 1e18); + + + t.start(); + auto got = got::bitonicTSP(); + t.stop(); + hash_t hash = 0; + for (auto x : got) hash += x; + if (t.time > 500) cerr << "too slow: " << t.time << FAIL; + cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl; +} + +int main() { + stress_test(); + if (!sanitize) performance_test(); +} |
