Pastey match() speed test

--
-- 
include std/console.e -- any_key 
include std/graphics.e -- for all the pretty screen formatting and colors 
 
without trace 
 
object junk = "" 
atom linecount = 0 
sequence haystack = {} 
atom starttime, time1, time2 
 
puts(1,"building haystack\n") 
 
for fillit = 1 to 10000000 do 
  haystack &= {"ppppp ppppp moose ppppp ppppp"} 
end for 
haystack[length(haystack)] = "ppppp ppppp x eleven ppppp" 
 
puts(1,"Running tests\n\n") 
 
 
 
function test1() 
object junk = "" 
starttime = time() 
 
  for test = 1 to length(haystack) do 
    if match("x",haystack[test]) then 
      --puts(1,"found it!") 
      junk = 1 
    end if 
  end for 
  junk = time()-starttime 
  puts(1,sprintf("%f",junk)) 
  return junk 
end function 
 
function test2() 
object junk = "" 
starttime = time() 
 
  for test = 1 to length(haystack) do 
    if match("eleven",haystack[test]) then 
      --puts(1,"found it!") 
      junk = 1 
    end if 
  end for 
  junk = time()-starttime 
  puts(1,sprintf("%f",junk)) 
  return junk 
end function 
 
--main-- 
linecount = 4 -- start here 
 
for testloop = 1 to 10 do 
 
  linecount += 1 -- newline 
  position(linecount,1) 
  time1 = test1() 
  position(linecount,15) 
  time2 = test2() 
 
  position(linecount,30) 
  if (time1 < time2) 
    then puts(1,"time1 is faster") 
    else puts(1,"time2 is faster") 
  end if  
 
  linecount += 1 -- newline 
  position(linecount,15) 
  time2 = test2() 
  position(linecount,1) 
  time1 = test1() 
 
  position(linecount,30) 
  if (time1 < time2) 
    then puts(1,"time1 is faster") 
    else puts(1,"time2 is faster") 
  end if  
 
end for 
 
position(linecount+2,1) 
any_key("press a key to abort") 
 
 
--