Created
September 30, 2014 07:52
-
-
Save huacnlee/014292aee825adad76b8 to your computer and use it in GitHub Desktop.
String freeze vs no freeze
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
task :test_string_freeze_vs_nofreeze do | |
str = "this is a example string" | |
Benchmark.ips do |x| | |
x.report("no_freeze") { | |
str.index("example") | |
} | |
x.report("freeze") { | |
str.index("example".freeze) | |
} | |
x.compare! | |
end | |
end |
Author
huacnlee
commented
Sep 30, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment