summaryrefslogtreecommitdiff
path: root/test/math/transforms/xorTransform.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/math/transforms/xorTransform.cpp
parentad3856a6b766087df0036de0b556f4700a6498c9 (diff)
parent8d11c6c8213f46f0fa19826917c255edd5d43cb1 (diff)
mzuenni tests
Diffstat (limited to 'test/math/transforms/xorTransform.cpp')
-rw-r--r--test/math/transforms/xorTransform.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/math/transforms/xorTransform.cpp b/test/math/transforms/xorTransform.cpp
new file mode 100644
index 0000000..17b0f6f
--- /dev/null
+++ b/test/math/transforms/xorTransform.cpp
@@ -0,0 +1,38 @@
+#include "../../util.h"
+#include <math/transforms/xorTransform.cpp>
+
+void stress_test() {
+ ll queries = 0;
+ for (ll i = 0; i < 10'000; i++) {
+ int n = 1ll << Random::integer<int>(0, 10);
+ auto expected = Random::integers<ll>(n, -1000, 1000);
+ auto got = expected;
+ fft(got, false);
+ fft(got, true);
+ if (got != expected) cerr << "error" << FAIL;
+ queries += n;
+ }
+ cerr << "tested queries: " << queries << endl;
+}
+
+constexpr int N = 1ll << 23;
+void performance_test() {
+ timer t;
+ vector<ll> a = Random::integers<ll>(N, -1000, 1000);
+ vector<ll> b = Random::integers<ll>(N, -1000, 1000);
+ t.start();
+ fft(a, true);
+ fft(b, false);
+ t.stop();
+ hash_t hash = 0;
+ for (ll i = 0; i < N; i++) hash += i * a[i];
+ for (ll i = 0; i < N; i++) hash += i * b[i];
+ 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();
+}
+