Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Created a tool to show us the sizes of various data structures.

  • Loading branch information...
commit 44ec7ca57dd9241e178d65001105b7d100a7dd50 1 parent a456210
@dustin dustin authored
Showing with 33 additions and 2 deletions.
  1. +1 −0  .gitignore
  2. +3 −2 Makefile.am
  3. +29 −0 sizes.c
View
1  .gitignore
@@ -32,3 +32,4 @@ memcached_dtrace.h
memcached-*.tar.gz
doc/protocol-binary-range.txt
doc/protocol-binary.txt
+/sizes
View
5 Makefile.am
@@ -1,4 +1,4 @@
-bin_PROGRAMS = memcached memcached-debug
+bin_PROGRAMS = memcached memcached-debug sizes
pkginclude_HEADERS = protocol_binary.h
BUILT_SOURCES=
@@ -58,7 +58,8 @@ EXTRA_DIST = doc scripts TODO t memcached.spec memcached_dtrace.d
MOSTLYCLEANFILES = *.gcov *.gcno *.gcda *.tcov
-test: memcached-debug
+test: memcached-debug sizes
+ $(srcdir)/sizes
prove $(srcdir)/t
@if test `basename $(PROFILER)` = "gcov"; then \
for file in memcached_debug-*.gc??; do \
View
29 sizes.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+
+#include "memcached.h"
+
+static void display(const char *name, size_t size) {
+ printf("%s\t%d\n", name, (int)size);
+}
+
+int main(int argc, char **argv) {
+
+ display("Slab Stats", sizeof(struct slab_stats));
+ display("Thread stats",
+ sizeof(struct thread_stats)
+ - (200 * sizeof(struct slab_stats)));
+ display("Global stats", sizeof(struct stats));
+ display("Settings", sizeof(struct settings));
+ display("Item (no cas)", sizeof(item));
+ display("Item (cas)", sizeof(item) + sizeof(uint64_t));
+ display("Libevent thread",
+ sizeof(LIBEVENT_THREAD) - sizeof(struct thread_stats));
+ display("Connection", sizeof(conn));
+
+ printf("----------------------------------------\n");
+
+ display("libevent thread cumulative", sizeof(LIBEVENT_THREAD));
+ display("Thread stats cumulative\t", sizeof(struct thread_stats));
+
+ return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.