AhlsBenchmark.frink

Download or view AhlsBenchmark.frink in plain text format


/** Ahl's simple benchmark, Creative Computing March 1984, P. 6

https://archive.org/details/CreativeComputingbetterScan198403/page/n7/mode/1up
*/


for times = 1 to 200
{
   start = now[]
   s = 0
   r = 0
   for n = 1 to 100
   {
      a = n
      for i = 1 to 10
      {
         a = sqrt[a,prec]
         r = r + randomFloat[0,1]
      }

      for i = 1 to 10
      {
         a = a^2
         r = r + randomFloat[0,1]
      }

      s = s + a
   }

   println["Accuracy: " + abs[1010-s/5]]
   println["Random:   " + formatFix[abs[1000-r], 1, 1]]
   end = now[]
   println["Time:     " + ((end-start) -> "ms")]
   println[]
}


Download or view AhlsBenchmark.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20145 days, 19 hours, 10 minutes ago.