summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-10-19 00:59:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:27 -0500
commitcd2bc5854ca4f5aefb80e3599c1639c2badc7da9 (patch)
treeec6ce2a390bd1a95f240823064dd04314fa5edf0
parentd6db8e6cb8e60e82328deda1bb5d940859deb0b7 (diff)
downloadsamba-cd2bc5854ca4f5aefb80e3599c1639c2badc7da9.tar.gz
samba-cd2bc5854ca4f5aefb80e3599c1639c2badc7da9.tar.bz2
samba-cd2bc5854ca4f5aefb80e3599c1639c2badc7da9.zip
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)
-rw-r--r--source4/lib/talloc/testsuite.c31
1 files changed, 18 insertions, 13 deletions
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<loop;i++) {
+ p1 = talloc_size(ctx, loop % 100);
+ p2 = talloc_strdup(p1, "foo bar");
+ p3 = talloc_size(p1, 300);
+ talloc_free(p1);
+ }
+ count += 3 * loop;
} while (timeval_elapsed(&tv) < 5.0);
fprintf(stderr, "talloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
@@ -814,15 +818,16 @@ static bool test_speed(void)
count = 0;
do {
void *p1, *p2, *p3;
- p1 = malloc(count);
- p2 = strdup("foo bar");
- p3 = malloc(300);
- free(p1);
- free(p2);
- free(p3);
- count += 3;
+ for (i=0;i<loop;i++) {
+ p1 = malloc(loop % 100);
+ p2 = strdup("foo bar");
+ p3 = malloc(300);
+ free(p1);
+ free(p2);
+ free(p3);
+ }
+ count += 3 * loop;
} while (timeval_elapsed(&tv) < 5.0);
-
fprintf(stderr, "malloc: %.0f ops/sec\n", count/timeval_elapsed(&tv));
printf("success: speed\n");