From owner-freebsd-current Mon Dec 9 21:51:16 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id VAA15658 for current-outgoing; Mon, 9 Dec 1996 21:51:16 -0800 (PST) Received: from motaba.tmc.edu.tw (motaba.tmc.edu.tw [203.64.48.253]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id VAA15649 for ; Mon, 9 Dec 1996 21:51:06 -0800 (PST) From: alexj@motaba.tmc.edu.tw Received: from [203.64.48.13] by motaba.tmc.edu.tw (AIX 3.2/UCB 5.64/4.03) id AA19060; Tue, 10 Dec 1996 13:53:25 +0800 Date: Tue, 10 Dec 1996 13:53:25 +0800 Message-Id: <3.0.32.19961210135325.00de1af0@mail.tmc.edu.tw> X-Sender: alexj@mail.tmc.edu.tw (Unverified) X-Mailer: Windows Eudora Pro Version 3.0 (32) To: freebsd-current@freebsd.org Subject: Amazing to MIT Pthread-1.60b6 & Pthread built in FreeBSD-2.2-ALPHA Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=====================_850254808==_" Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk --=====================_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 #include 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 ffff,0000,0000Eudora Pro 3, = = You will find that the world of e-mail can also be ffff,0000,ffffco0000,0000,fffflo0000,ffff,ffffrf0000,ffff,0000ul = ======================================================== --=====================_850254808==_--