<div>I am a newbie to the GMP</div> <div>and trying to run some example codes !</div> <div> </div> <div>I find the result of gmp-chudnovsky.c running strange on my computer. It shows the efficiency of the mpf_out_str function seems to be very low. When I try to calculate 800000 digits of pi , the core calculation take 13.6 sec , but the digits print-out task take more than 56 sec ( use a stop watch)</div> <div> </div> <div>why ??</div> <div> </div> <div>Jason Lin</div> <div> </div> <div>the following are the details</div> <div>-------------------</div> <div> </div> <div>djgpp 2.03<BR>with gmp 4.1.2 (precompiled package)<BR>on a Windows XP command console running with Pentium-4 1.6 GHz / 1G RAM</div> <div> </div> <div>d:\dp>gcc -Wall -O2 -s -o chud.exe gmp-chudnovsky.c -lm -lgmp</div> <div> </div> <div>case1:</div> <div>d:\dp>chud 500000 1 <- to get
500000 digits</div> <div>#terms=35256, depth=17<BR>sieve time = 0.000<BR>...................................................<BR>bs time = 5.110<BR> gcd time = 0.330<BR>div time = 1.099<BR>sqrt time = 0.604<BR>mul time = 0.385<BR>total time = 7.198<BR> P size=727581 digits (1.455162)<BR> Q size=727575 digits (1.455150)<BR>pi(0,35256)=</div> <div>Totally 29 sec to get the final result<BR>(22 sec for the mpf_out_str function )</div> <div> </div> <div> </div> <div>case2:<BR>d:\dp>chud 800000 1 <- to get 800000 digits<BR>#terms=56410, depth=17<BR>sieve time = 0.000<BR>...................................................<BR>bs time = 10.000<BR> gcd time =
0.495<BR>div time = 1.923<BR>sqrt time = 0.989<BR>mul time = 0.714<BR>total time = 13.626<BR> P size=1164133 digits (1.455166)<BR> Q size=1164127 digits (1.455159)<BR>pi(0,56410)=</div> <div>Totally 69 sec to get the final result<BR>(56 sec for the mpf_out_str function )</div> <div> </div> <div>---------------------------------------------</div> <div>print out code in gmp-chudnovsky.c</div> <div> </div> <div>if (out&1) {<BR> printf("pi(0,%ld)=\n", terms);<BR> mpf_out_str(stdout, 10, d+2, qi); <---- it is the hot spot<BR> printf("\n");</div><p> 
___________________________________________________________________<br>
體驗全新Yahoo!奇摩電子信箱2.0 - <a href="http://tw.rd.yahoo.com/referurl/mail/mail20/tag_1022/*http://tw.mg0.mail.yahoo.com/dc/landing"><strong>馬上體驗</strong></a>!