svn commit: samba r19405 - in branches/SAMBA_4_0/source/lib/talloc: .

tridge at samba.org tridge at samba.org
Thu Oct 19 00:59:34 GMT 2006


Author: tridge
Date: 2006-10-19 00:59:33 +0000 (Thu, 19 Oct 2006)
New Revision: 19405

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19405

Log:

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.

Modified:
   branches/SAMBA_4_0/source/lib/talloc/testsuite.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/talloc/testsuite.c
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/testsuite.c	2006-10-18 23:27:48 UTC (rev 19404)
+++ branches/SAMBA_4_0/source/lib/talloc/testsuite.c	2006-10-19 00:59:33 UTC (rev 19405)
@@ -791,6 +791,8 @@
 {
 	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 @@
 	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 @@
 	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");



More information about the samba-cvs mailing list