aboutsummaryrefslogtreecommitdiff
path: root/examples/redis-unstable/deps/jemalloc/test/stress/fill_flush.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/redis-unstable/deps/jemalloc/test/stress/fill_flush.c')
-rw-r--r--examples/redis-unstable/deps/jemalloc/test/stress/fill_flush.c76
1 files changed, 0 insertions, 76 deletions
diff --git a/examples/redis-unstable/deps/jemalloc/test/stress/fill_flush.c b/examples/redis-unstable/deps/jemalloc/test/stress/fill_flush.c
deleted file mode 100644
index a2db044..0000000
--- a/examples/redis-unstable/deps/jemalloc/test/stress/fill_flush.c
+++ /dev/null
@@ -1,76 +0,0 @@
1#include "test/jemalloc_test.h"
2#include "test/bench.h"
3
4#define SMALL_ALLOC_SIZE 128
5#define LARGE_ALLOC_SIZE SC_LARGE_MINCLASS
6#define NALLOCS 1000
7
8/*
9 * We make this volatile so the 1-at-a-time variants can't leave the allocation
10 * in a register, just to try to get the cache behavior closer.
11 */
12void *volatile allocs[NALLOCS];
13
14static void
15array_alloc_dalloc_small(void) {
16 for (int i = 0; i < NALLOCS; i++) {
17 void *p = mallocx(SMALL_ALLOC_SIZE, 0);
18 assert_ptr_not_null(p, "mallocx shouldn't fail");
19 allocs[i] = p;
20 }
21 for (int i = 0; i < NALLOCS; i++) {
22 sdallocx(allocs[i], SMALL_ALLOC_SIZE, 0);
23 }
24}
25
26static void
27item_alloc_dalloc_small(void) {
28 for (int i = 0; i < NALLOCS; i++) {
29 void *p = mallocx(SMALL_ALLOC_SIZE, 0);
30 assert_ptr_not_null(p, "mallocx shouldn't fail");
31 allocs[i] = p;
32 sdallocx(allocs[i], SMALL_ALLOC_SIZE, 0);
33 }
34}
35
36TEST_BEGIN(test_array_vs_item_small) {
37 compare_funcs(1 * 1000, 10 * 1000,
38 "array of small allocations", array_alloc_dalloc_small,
39 "small item allocation", item_alloc_dalloc_small);
40}
41TEST_END
42
43static void
44array_alloc_dalloc_large(void) {
45 for (int i = 0; i < NALLOCS; i++) {
46 void *p = mallocx(LARGE_ALLOC_SIZE, 0);
47 assert_ptr_not_null(p, "mallocx shouldn't fail");
48 allocs[i] = p;
49 }
50 for (int i = 0; i < NALLOCS; i++) {
51 sdallocx(allocs[i], LARGE_ALLOC_SIZE, 0);
52 }
53}
54
55static void
56item_alloc_dalloc_large(void) {
57 for (int i = 0; i < NALLOCS; i++) {
58 void *p = mallocx(LARGE_ALLOC_SIZE, 0);
59 assert_ptr_not_null(p, "mallocx shouldn't fail");
60 allocs[i] = p;
61 sdallocx(allocs[i], LARGE_ALLOC_SIZE, 0);
62 }
63}
64
65TEST_BEGIN(test_array_vs_item_large) {
66 compare_funcs(100, 1000,
67 "array of large allocations", array_alloc_dalloc_large,
68 "large item allocation", item_alloc_dalloc_large);
69}
70TEST_END
71
72int main(void) {
73 return test_no_reentrancy(
74 test_array_vs_item_small,
75 test_array_vs_item_large);
76}