Low efficiency of the mpf_out_str function !

賴 秀琴 chyn0610 at yahoo.com.tw
Wed Nov 7 14:39:13 CET 2007


I am a newbie to the GMP
  and trying to run some example codes !
   
  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)
   
  why ??
   
  Jason Lin
   
  the following are the details
  -------------------
   
  djgpp 2.03
with gmp 4.1.2 (precompiled package)
on a Windows XP command console running with Pentium-4 1.6 GHz / 1G RAM
   
  d:\dp>gcc -Wall -O2 -s -o chud.exe gmp-chudnovsky.c -lm -lgmp
   
  case1:
  d:\dp>chud 500000 1           <-  to get 500000 digits
  #terms=35256, depth=17
sieve   time =  0.000
...................................................
bs      time =  5.110
   gcd  time =  0.330
div     time =  1.099
sqrt    time =  0.604
mul     time =  0.385
total   time =  7.198
   P size=727581 digits (1.455162)
   Q size=727575 digits (1.455150)
pi(0,35256)=
  Totally 29 sec to get the final result
(22 sec for the mpf_out_str function )
   
   
  case2:
d:\dp>chud 800000 1    <- to get 800000 digits
#terms=56410, depth=17
sieve   time =  0.000
...................................................
bs      time = 10.000
   gcd  time =  0.495
div     time =  1.923
sqrt    time =  0.989
mul     time =  0.714
total   time = 13.626
   P size=1164133 digits (1.455166)
   Q size=1164127 digits (1.455159)
pi(0,56410)=
  Totally 69 sec to get the final result
(56 sec for the mpf_out_str function )
   
  ---------------------------------------------
  print out code in gmp-chudnovsky.c
   
  if (out&1)  {
    printf("pi(0,%ld)=\n", terms);
    mpf_out_str(stdout, 10, d+2, qi);      <---- it is the hot spot
    printf("\n");

       ___________________________________________________________________
體驗全新Yahoo!奇摩電子信箱2.0 - 馬上體驗!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gmplib.org/list-archives/gmp-discuss/attachments/20071107/e96a8987/attachment.html 


More information about the gmp-discuss mailing list