vectest.frink

Download or view vectest.frink in plain text format


// Vector math timing test

size = million

a = new array[[size], {|x| random[1, billion]}]
b = new array[[size], {|x| random[1, billion]}]
println["Arrays allocated."]

sum1 = 0 s
sum2 = 0 s
for iter = 1 to 30
{
   start1 = now[]
   c = new array[size]
   for i=0 to size-1
      c@i = a@i * b@i

   end1 = now[]


   start2 = now[]
   d = mul[a,b]
   end2 = now[]
   if c != d
      println["Mismatch!"]

   t1 = end1-start1
   t2 = end2-start2
   sum1 = sum1 + t1
   sum2 = sum2 + t2
   println["Iter: " + (t1 -> "ms") + "\tvec: " + (t2->"ms")]
}

println["Speedup is " + formatFix[sum1/sum2, 1, 4]]


Download or view vectest.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 20217 days, 23 hours, 26 minutes ago.