summaryrefslogtreecommitdiff
path: root/test/graph/bitonicTSPsimple.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
commit98567ec798aa8ca2cfbcb85c774dd470f30e30d4 (patch)
tree5113d5cc24d1ad5f93810b6442ce584a36950dc8 /test/graph/bitonicTSPsimple.cpp
parentad3856a6b766087df0036de0b556f4700a6498c9 (diff)
parent8d11c6c8213f46f0fa19826917c255edd5d43cb1 (diff)
mzuenni tests
Diffstat (limited to 'test/graph/bitonicTSPsimple.cpp')
-rw-r--r--test/graph/bitonicTSPsimple.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/graph/bitonicTSPsimple.cpp b/test/graph/bitonicTSPsimple.cpp
new file mode 100644
index 0000000..c79a0ef
--- /dev/null
+++ b/test/graph/bitonicTSPsimple.cpp
@@ -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>(1, 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 = got::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();
+ performance_test();
+}