From ccddec68116fc6403858ebfa13d4a7b1aa3d5278 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Sun, 18 Oct 2009 20:01:19 +0000 Subject: hi gridflow 0.9.5 svn path=/trunk/; revision=12611 --- externals/gridflow/tests/malloc-test.c | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 externals/gridflow/tests/malloc-test.c (limited to 'externals/gridflow/tests/malloc-test.c') diff --git a/externals/gridflow/tests/malloc-test.c b/externals/gridflow/tests/malloc-test.c new file mode 100644 index 00000000..d5445dcc --- /dev/null +++ b/externals/gridflow/tests/malloc-test.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +typedef long long uint64; + +uint64 gf_timeofday () { + timeval t; + gettimeofday(&t,0); + return t.tv_sec*1000000+t.tv_usec; +} +static void test1 (size_t n) { + uint64 t = gf_timeofday(); + for (int i=0; i<10000; i++) free(malloc(n)); + t = gf_timeofday() - t; + printf("10000 mallocs of %7ld bytes takes %7ld us (%f us/malloc)\n",n,(long)t,t/(float)10000); +} +static void test2 (size_t n) { + uint64 t = gf_timeofday(); + // the real calloc is lazy, let's try a manual (strict) calloc + //for (int i=0; i<10000; i++) free(calloc(1,n)); + for (int i=0; i<10000; i++) { + long *p = (long *)malloc(n); + size_t nn=n/sizeof(long); + for (size_t j=0; j