#!/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 the default case, which simply checks the string using the RE. # "-" is ASCII 45 s1 = "This is a test." s2 = "Wednesday is another day." s3 = "---*** A Possible Heading" time_start = Time::now 10000.times do /\A---\*{3}/ =~ s1 /\A---\*{3}/ =~ s2 /\A---\*{3}/ =~ s3 end puts (Time::now - time_start).to_s