File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1004,6 +1004,24 @@ Comparison:
1004
1004
String#gsub: 516604.2 i/s - 3.60x slower
1005
1005
```
1006
1006
1007
+ ##### ` Mutable ` vs ` Immutable ` [ code] ( code/string/mutable_vs_immutable_strings.rb )
1008
+
1009
+ ```
1010
+ $ ruby -v code/string/mutable_vs_immutable_strings.rb
1011
+ ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
1012
+ Warming up --------------------------------------
1013
+ freeze 111.292k i/100ms
1014
+ normal 106.928k i/100ms
1015
+ Calculating -------------------------------------
1016
+ freeze 5.282M (±14.2%) i/s - 25.931M
1017
+ normal 4.549M (±14.3%) i/s - 22.348M
1018
+
1019
+ Comparison:
1020
+ freeze: 5281661.4 i/s
1021
+ normal: 4548975.9 i/s - same-ish: difference falls within error
1022
+ ```
1023
+
1024
+
1007
1025
##### ` String#sub! ` vs ` String#gsub! ` vs ` String#[]= ` [ code] ( code/string/sub!-vs-gsub!-vs-[]=.rb )
1008
1026
1009
1027
Note that ` String#[] ` will throw an ` IndexError ` when given string or regexp not matched.
You can’t perform that action at this time.
0 commit comments