Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Dec 1996 13:53:25 +0800
From:      alexj@motaba.tmc.edu.tw
To:        freebsd-current@freebsd.org
Subject:   Amazing to MIT Pthread-1.60b6 & Pthread built in FreeBSD-2.2-ALPHA
Message-ID:  <3.0.32.19961210135325.00de1af0@mail.tmc.edu.tw>

next in thread | raw e-mail | index | archive | help
--=====================_850254808==_
Content-Type: text/enriched; charset="us-ascii"

It surprised me so much !!

	I wrote a small program to test the performance of MIT PThread-1.60b6 (MIT) used in FreeBSD-2.2-ALPHA & the pthread built in FBSD-2.2-ALPHA (FBSD).

	I had thought that the performance of FBSD should be better than that of

MIT. However, I am wrong after making this test.

	It's really amazing. The performance of MIT is much better than that

of FBSD.

	Is there any problem in FreeBSD-2.2-ALPHA ?


gcc pbench.c -lc_r

================================================================

FreeBSD 2.2-ALPHA built-in PTHREAD test....

Testing pthread_create() 1000 times...spending 3.228051 seconds

Testing pthread_lock()  10000 times...spending 0.97357 seconds

Testing pthread_yield() 10000 times...spending 12.1259162 seconds

================================================================


pgcc pbench.c

================================================================

MIT PTHREAD 1.60B6 performance test....

Testing pthread_create() 100000 times...spending 0.1063555 seconds

Testing pthread_lock()  1000000 times...spending 1.168608 seconds

Testing pthread_yield() 1000000 times...spending 9.333843 seconds

==================================================================


The attachment is my program source code


--=====================_850254808==_
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: attachment; filename="pbench.c"

#include <pthread.h>
#include <stdio.h>

struct timeval tv1, tv2;
long testTimes=100;

void create_thread_test()
{
	pthread_exit(0);
}

void test_pthread_create()
{
	int count;
	long d_sec, d_usec, tt;
	pthread_t p_t;
	
	tt = testTimes / 10;
	printf("Testing pthread_create() %i times...", tt);
	gettimeofday(&tv1, NULL);
	for(count=0; count < tt; count++) {
		pthread_create(&p_t, NULL, (void*) &create_thread_test, NULL);
	}
	gettimeofday(&tv2, NULL);
	d_usec = tv2.tv_usec-tv1.tv_usec;
	d_sec = tv2.tv_sec-tv1.tv_sec;
	if (d_usec < 0) {
		d_usec = 1000000- d_usec;
		d_sec--;
	}
	printf("spending %i.%i seconds\n",d_sec,d_usec);
}

void test_pthread_lock()
{
	int count;
	long d_sec, d_usec;
	pthread_mutex_t  lock;
	
	printf("Testing pthread_lock()  %i times...", testTimes);
	pthread_mutex_init(&lock, NULL);
	gettimeofday(&tv1, NULL);
	for(count=0; count < testTimes; count++) {
		pthread_mutex_lock(&lock);
		pthread_mutex_unlock(&lock);
	}
	gettimeofday(&tv2, NULL);
	d_usec = tv2.tv_usec-tv1.tv_usec;
	d_sec = tv2.tv_sec-tv1.tv_sec;
	if (d_usec < 0) {
		d_usec = 1000000- d_usec;
		d_sec--;
	}
	printf("spending %i.%i seconds\n",d_sec,d_usec);

}


void test_pthread_yield()
{
	int count;
	long d_sec, d_usec;
	
	printf("Testing pthread_yield() %i times...", testTimes);
	gettimeofday(&tv1, NULL);
	for(count=0; count < testTimes; count++) {
		pthread_yield();
	}
	gettimeofday(&tv2, NULL);
	d_usec = tv2.tv_usec-tv1.tv_usec;
	d_sec = tv2.tv_sec-tv1.tv_sec;
	if (d_usec < 0) {
		d_usec = 1000000- d_usec;
		d_sec--;
	}
	printf("spending %i.%i seconds\n",d_sec,d_usec);

}




//================================================================
main(argc, argv)
int argc;
char *argv[];
{
	int i;
	pthread_init();
	
	printf("argc=%i\n", argc);
	for (i=0; i < argc; i++) {
		printf("argv[%i]=%s\n", i, argv[i]);
	}
	if (argc >=2) {
		testTimes = atoi(argv[1]);
	}
	
//#define MIT
#ifdef MIT
	printf("MIT PTHREAD 1.60B6 performance test....\n");
#else
	printf("FreeBSD 2.2-ALPHA built-in PTHREAD test....\n");
#endif
	
	test_pthread_create();
	test_pthread_lock();
	test_pthread_yield();
	

}

--=====================_850254808==_
Content-Type: text/enriched; charset="us-ascii"



========================================================

= 	      Reading this letter thorugh
<bold><color><param>ffff,0000,0000</param><bigger><bigger>E</bigger></bigger>u<bigger>d</bigger>ora
<bigger><bigger>P</bigger></bigger>ro
<bigger><bigger>3</bigger></bigger></color></bold>,		=

=                You will find that the world of e-mail can also be
<color><param>ffff,0000,ffff</param>co</color><color><param>0000,0000,ffff</param>lo</color><color><param>0000,ffff,ffff</param>rf</color><color><param>0000,ffff,0000</param>ul</color>		=

========================================================
--=====================_850254808==_--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.32.19961210135325.00de1af0>