Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

18 lines (14 sloc) 341 Bytes
require "benchmark/ips"
# Allocates new string over and over again
def without_freeze
"To freeze or not to freeze"
end
# Keeps and reuses shared string
def with_feeze
"To freeze or not to freeze".freeze
end
Benchmark.ips do |x|
x.report("Without Freeze") { without_freeze }
x.report("With Freeze") { with_feeze }
x.compare!
end
You can’t perform that action at this time.