summaryrefslogtreecommitdiff
path: root/test/analyze/sizes.c
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2022-05-06 11:28:25 -0700
committerQi Wang <interwq@gwu.edu>2022-05-06 11:28:25 -0700
commit54eaed1d8b56b1aa528be3bdd1877e59c56fa90c (patch)
treee79620e0c00b1f8b6b698fbe74df6bae7d812ae2 /test/analyze/sizes.c
parentea6b3e973b477b8061e0076bb257dbd7f3faa756 (diff)
parent304c919829f9f340669b61fa64867cfe5dba8021 (diff)
downloadjemalloc-master.tar.gz
Merge branch 'dev'5.3.0master
Diffstat (limited to 'test/analyze/sizes.c')
-rw-r--r--test/analyze/sizes.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/analyze/sizes.c b/test/analyze/sizes.c
new file mode 100644
index 00000000..44c9de5e
--- /dev/null
+++ b/test/analyze/sizes.c
@@ -0,0 +1,53 @@
+#include "test/jemalloc_test.h"
+
+#include <stdio.h>
+
+/*
+ * Print the sizes of various important core data structures. OK, I guess this
+ * isn't really a "stress" test, but it does give useful information about
+ * low-level performance characteristics, as the other things in this directory
+ * do.
+ */
+
+static void
+do_print(const char *name, size_t sz_bytes) {
+ const char *sizes[] = {"bytes", "KB", "MB", "GB", "TB", "PB", "EB",
+ "ZB"};
+ size_t sizes_max = sizeof(sizes)/sizeof(sizes[0]);
+
+ size_t ind = 0;
+ double sz = sz_bytes;
+ while (sz >= 1024 && ind < sizes_max - 1) {
+ sz /= 1024;
+ ind++;
+ }
+ if (ind == 0) {
+ printf("%-20s: %zu bytes\n", name, sz_bytes);
+ } else {
+ printf("%-20s: %f %s\n", name, sz, sizes[ind]);
+ }
+}
+
+int
+main() {
+#define P(type) \
+ do_print(#type, sizeof(type))
+ P(arena_t);
+ P(arena_stats_t);
+ P(base_t);
+ P(decay_t);
+ P(edata_t);
+ P(ecache_t);
+ P(eset_t);
+ P(malloc_mutex_t);
+ P(prof_tctx_t);
+ P(prof_gctx_t);
+ P(prof_tdata_t);
+ P(rtree_t);
+ P(rtree_leaf_elm_t);
+ P(slab_data_t);
+ P(tcache_t);
+ P(tcache_slow_t);
+ P(tsd_t);
+#undef P
+}