We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d6e1ac0 commit 8d9e752Copy full SHA for 8d9e752
code/string/mutable_vs_immutable_strings.rb
@@ -0,0 +1,12 @@
1
+require 'benchmark/ips'
2
+
3
+IMMUTABLE_TEST = "writing_fast_ruby".freeze
4
+mutable_test = "writing_fast_ruby"
5
6
+hash = {"writing_fast_ruby" => "is_cool"}
7
8
+Benchmark.ips do |x|
9
+ x.report("freeze") { hash[IMMUTABLE_TEST] }
10
+ x.report("normal") { hash[mutable_test] }
11
+ x.compare!
12
+end
0 commit comments