Skip to content

Commit

Permalink
Created a tool to show us the sizes of various data structures.
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin committed Mar 10, 2009
1 parent a456210 commit 44ec7ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -32,3 +32,4 @@ memcached_dtrace.h
memcached-*.tar.gz memcached-*.tar.gz
doc/protocol-binary-range.txt doc/protocol-binary-range.txt
doc/protocol-binary.txt doc/protocol-binary.txt
/sizes
5 changes: 3 additions & 2 deletions Makefile.am
@@ -1,4 +1,4 @@
bin_PROGRAMS = memcached memcached-debug bin_PROGRAMS = memcached memcached-debug sizes
pkginclude_HEADERS = protocol_binary.h pkginclude_HEADERS = protocol_binary.h


BUILT_SOURCES= BUILT_SOURCES=
Expand Down Expand Up @@ -58,7 +58,8 @@ EXTRA_DIST = doc scripts TODO t memcached.spec memcached_dtrace.d


MOSTLYCLEANFILES = *.gcov *.gcno *.gcda *.tcov MOSTLYCLEANFILES = *.gcov *.gcno *.gcda *.tcov


test: memcached-debug test: memcached-debug sizes
$(srcdir)/sizes
prove $(srcdir)/t prove $(srcdir)/t
@if test `basename $(PROFILER)` = "gcov"; then \ @if test `basename $(PROFILER)` = "gcov"; then \
for file in memcached_debug-*.gc??; do \ for file in memcached_debug-*.gc??; do \
Expand Down
29 changes: 29 additions & 0 deletions 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;
}

0 comments on commit 44ec7ca

Please sign in to comment.