Skip to content

Commit 44ec7ca

Browse files
committedMar 10, 2009
Created a tool to show us the sizes of various data structures.
1 parent a456210 commit 44ec7ca

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ memcached_dtrace.h
3232
memcached-*.tar.gz
3333
doc/protocol-binary-range.txt
3434
doc/protocol-binary.txt
35+
/sizes

‎Makefile.am

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bin_PROGRAMS = memcached memcached-debug
1+
bin_PROGRAMS = memcached memcached-debug sizes
22
pkginclude_HEADERS = protocol_binary.h
33

44
BUILT_SOURCES=
@@ -58,7 +58,8 @@ EXTRA_DIST = doc scripts TODO t memcached.spec memcached_dtrace.d
5858

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

61-
test: memcached-debug
61+
test: memcached-debug sizes
62+
$(srcdir)/sizes
6263
prove $(srcdir)/t
6364
@if test `basename $(PROFILER)` = "gcov"; then \
6465
for file in memcached_debug-*.gc??; do \

‎sizes.c

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <stdio.h>
2+
3+
#include "memcached.h"
4+
5+
static void display(const char *name, size_t size) {
6+
printf("%s\t%d\n", name, (int)size);
7+
}
8+
9+
int main(int argc, char **argv) {
10+
11+
display("Slab Stats", sizeof(struct slab_stats));
12+
display("Thread stats",
13+
sizeof(struct thread_stats)
14+
- (200 * sizeof(struct slab_stats)));
15+
display("Global stats", sizeof(struct stats));
16+
display("Settings", sizeof(struct settings));
17+
display("Item (no cas)", sizeof(item));
18+
display("Item (cas)", sizeof(item) + sizeof(uint64_t));
19+
display("Libevent thread",
20+
sizeof(LIBEVENT_THREAD) - sizeof(struct thread_stats));
21+
display("Connection", sizeof(conn));
22+
23+
printf("----------------------------------------\n");
24+
25+
display("libevent thread cumulative", sizeof(LIBEVENT_THREAD));
26+
display("Thread stats cumulative\t", sizeof(struct thread_stats));
27+
28+
return 0;
29+
}

0 commit comments

Comments
 (0)
Please sign in to comment.