From cd2bc5854ca4f5aefb80e3599c1639c2badc7da9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 19 Oct 2006 00:59:33 +0000 Subject: r19405: the talloc speed test suite was not giving an accurate picture of the cost of talloc versus malloc. The size parameter in the test suite was constantly increasing, leading to a worst case for malloc. It is far more common to have talloc calls of 100 bytes or lower, so change the benchmark to reflect this. This makes talloc look much worse - on my laptop I now get: talloc: 5615164 ops/sec malloc: 14337130 ops/sec I'm working on improving that. (This used to be commit db273ef4dd6ab58da57bb4b59fb1fd5568585ed8) --- source4/lib/talloc/testsuite.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'source4/lib/talloc') diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c index 0658a931d0..f51252e57b 100644 --- a/source4/lib/talloc/testsuite.c +++ b/source4/lib/talloc/testsuite.c @@ -791,6 +791,8 @@ static bool test_speed(void) { void *ctx = talloc_new(NULL); unsigned count; + const int loop = 1000; + int i; struct timeval tv; printf("test: speed [\nTALLOC VS MALLOC SPEED\n]\n"); @@ -799,11 +801,13 @@ static bool test_speed(void) count = 0; do { void *p1, *p2, *p3; - p1 = talloc_size(ctx, count); - p2 = talloc_strdup(p1, "foo bar"); - p3 = talloc_size(p1, 300); - talloc_free(p1); - count += 3; + for (i=0;i