Created
January 22, 2014 23:01
-
-
Save tamalw/8569226 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
Benchmark.bm do |b| | |
b.report "upcase " do | |
e = "Collaboratively administrate empowered markets via plug-and-play networks -- http://www.cipsum.com/" | |
1_000_000.times { e[0] == e[0].upcase } | |
end | |
b.report " /^[A-Z]/ " do | |
e = "Collaboratively administrate empowered markets via plug-and-play networks -- http://www.cipsum.com/" | |
1_000_000.times { e =~ /^[A-Z]/ } | |
end | |
b.report "include? " do | |
e = "Collaboratively administrate empowered markets via plug-and-play networks -- http://www.cipsum.com/" | |
1_000_000.times { ("A".."Z").include?(e.chr) } | |
end | |
b.report " /^[[:upper:]]/" do | |
e = "Collaboratively administrate empowered markets via plug-and-play networks -- http://www.cipsum.com/" | |
1_000_000.times { e =~ /^[[:upper:]]/ } | |
end | |
b.report "ord " do | |
e = "Collaboratively administrate empowered markets via plug-and-play networks -- http://www.cipsum.com/" | |
1_000_000.times { i = e.ord; i > 64 && i < 91 } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment