From: w_a_x_man@... Date: 2009-02-12T05:33:56+09:00 Subject: Re: Ruby vs Perl performance On Feb 11, 2:57 am, "William James" wrote: > Reid Thompson wrote: > > William James wrote: > > > > Using the functional language F#: > > > > 0.0400575999999999 on my laptop with 2GHz Pentium. > > > On same box using all C. > > Echo delay is 0s and 20842us -> 20842 microseconds = 0.020842 > > seconds.  This is an Intel(R) Core(TM)2 CPU 6320  @ 1.86GHz box w 2GB > > RAM running gentoo with entire system compiled with > > CFLAGS="-march=prescott -O2 -g -pipe" + feature splitdebug ( > > everything compiled with debug except mandInC ).  -rwxr-xr-x  1 > > rthompso staff         7104 2009-02-10 23:36 mandInC > > To make timing more accurate, let's calculate the set 100 times > but draw it only 1 time. > > Result:  1.99286559999999  (laptop with 2GHz Pentium M) > > (**  Note that bailout has been changed.  **) > let bailout = 4.0 > let max_iterations = 1000 > > let iterate ci cr = >   let rec loop zi zr i = >     if i > max_iterations then >       0 >     else >       let temp = zr * zi  and >         zr2 = zr * zr  and >         zi2 = zi * zi  in >       if zi2 + zr2 > bailout then >         i >       else >         loop (temp + temp + ci) (zr2 - zi2 + cr) (i + 1) >   in >   loop 0.0 0.0 1 > > let mandelbrot n = >   for y = -39 to 38 do >     if 1 = n then  print_endline ""  else (); >     for x = -39 to 38 do >       let i = iterate >         (float x / 40.0) (float y / 40.0 - 0.5) in >       if 1 = n then >         System.Console.Write( ( if 0 = i then "*" else " " ) ) >       else (); >     done >   done;; > > let start_time = Sys.time () in > for iter = 1 to 100 do >   mandelbrot iter > done; > print_endline ""; > System.Console.Write (Sys.time () - start_time); > print_endline ""; This is over twice as fast as the OCaml version. F# is impressive.