Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby quick benchmark
# alternatively use benchmark/ips
n = 100_000
data = "..."
Benchmark.ips do |benchmark|
benchmark.report("include?") do
n.times { data.to_s.downcase.include?('windows') }
end
benchmark.report("match?") do
n.times { %r{[W|w]indows}.match?(data) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment