#!/usr/bin/env ruby # This is one of several little programs to attempt to test the speed of # various means of using an RE to search a string. # This is a "supervisory" program that runs other tests multiple times and # averages the elapsed times for each for comparision purposes. # re_test1.rb and re_test2.rb must be in the same directory as this program # (or the locations and paths have to be set appropriately) and all programs # must be executable. iterations = 10000 time_start = Time::now etime1, etime2 = 0, 0 iterations.times do etime1 += `re_test1.rb`.chomp.to_f etime2 += `re_test2.rb`.chomp.to_f end puts iterations.to_s + " trials:" puts "Test 1: " + (etime1 / iterations).to_s puts "Test 2: " + (etime2 / iterations).to_s puts "Test 2 / Test 1: " + ((etime2 / iterations) / (etime1 / iterations)).to_s puts "Total time: " + (Time::now - time_start).to_s