summaryrefslogtreecommitdiffstats
path: root/deps/jemalloc/test/unit/peak.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:40:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:40:54 +0000
commit317c0644ccf108aa23ef3fd8358bd66c2840bfc0 (patch)
treec417b3d25c86b775989cb5ac042f37611b626c8a /deps/jemalloc/test/unit/peak.c
parentInitial commit. (diff)
downloadredis-upstream/5%7.2.4.tar.xz
redis-upstream/5%7.2.4.zip
Adding upstream version 5:7.2.4.upstream/5%7.2.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--deps/jemalloc/test/unit/peak.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/deps/jemalloc/test/unit/peak.c b/deps/jemalloc/test/unit/peak.c
new file mode 100644
index 0000000..1112978
--- /dev/null
+++ b/deps/jemalloc/test/unit/peak.c
@@ -0,0 +1,47 @@
+#include "test/jemalloc_test.h"
+
+#include "jemalloc/internal/peak.h"
+
+TEST_BEGIN(test_peak) {
+ peak_t peak = PEAK_INITIALIZER;
+ expect_u64_eq(0, peak_max(&peak),
+ "Peak should be zero at initialization");
+ peak_update(&peak, 100, 50);
+ expect_u64_eq(50, peak_max(&peak),
+ "Missed update");
+ peak_update(&peak, 100, 100);
+ expect_u64_eq(50, peak_max(&peak), "Dallocs shouldn't change peak");
+ peak_update(&peak, 100, 200);
+ expect_u64_eq(50, peak_max(&peak), "Dallocs shouldn't change peak");
+ peak_update(&peak, 200, 200);
+ expect_u64_eq(50, peak_max(&peak), "Haven't reached peak again");
+ peak_update(&peak, 300, 200);
+ expect_u64_eq(100, peak_max(&peak), "Missed an update.");
+ peak_set_zero(&peak, 300, 200);
+ expect_u64_eq(0, peak_max(&peak), "No effect from zeroing");
+ peak_update(&peak, 300, 300);
+ expect_u64_eq(0, peak_max(&peak), "Dalloc shouldn't change peak");
+ peak_update(&peak, 400, 300);
+ expect_u64_eq(0, peak_max(&peak), "Should still be net negative");
+ peak_update(&peak, 500, 300);
+ expect_u64_eq(100, peak_max(&peak), "Missed an update.");
+ /*
+ * Above, we set to zero while a net allocator; let's try as a
+ * net-deallocator.
+ */
+ peak_set_zero(&peak, 600, 700);
+ expect_u64_eq(0, peak_max(&peak), "No effect from zeroing.");
+ peak_update(&peak, 600, 800);
+ expect_u64_eq(0, peak_max(&peak), "Dalloc shouldn't change peak.");
+ peak_update(&peak, 700, 800);
+ expect_u64_eq(0, peak_max(&peak), "Should still be net negative.");
+ peak_update(&peak, 800, 800);
+ expect_u64_eq(100, peak_max(&peak), "Missed an update.");
+}
+TEST_END
+
+int
+main(void) {
+ return test_no_reentrancy(
+ test_peak);
+}