File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -969,17 +969,17 @@ Note that this can only be used for removing characters from the end of a string
969
969
970
970
```
971
971
$ ruby -v code/string/sub-vs-chomp.rb
972
- ruby 2.2.2p95 (2015-04-13 revision 50295 ) [x86_64-darwin13]
972
+ ruby 2.2.3p173 (2015-08-18 revision 51636 ) [x86_64-darwin13]
973
973
Calculating -------------------------------------
974
- String#sub/regexp/ 38.068k i/100ms
975
- String#chomp'string' 78.284k i/100ms
974
+ String#sub/regexp/ 42.816k i/100ms
975
+ String#chomp'string' 94.851k i/100ms
976
976
-------------------------------------------------
977
- String#sub/regexp/ 560.625k (±17.1 %) i/s - 2.703M
978
- String#chomp'string' 2.704M (±18.6 %) i/s - 12.839M
977
+ String#sub/regexp/ 660.509k (± 8.0 %) i/s - 3.297M
978
+ String#chomp'string' 2.803M (± 8.0 %) i/s - 13.943M
979
979
980
980
Comparison:
981
- String#chomp'string': 2703881.6 i/s
982
- String#sub/regexp/: 560625.4 i/s - 4.82x slower
981
+ String#chomp'string': 2803443.5 i/s
982
+ String#sub/regexp/: 660508.7 i/s - 4.24x slower
983
983
```
984
984
985
985
##### ` attr_accessor ` vs ` getter and setter ` [ code] ( code/general/attr-accessor-vs-getter-and-setter.rb )
Original file line number Diff line number Diff line change 3
3
SLUG = 'YourSubclassType'
4
4
5
5
def slow
6
- SLUG . sub ( /Type$ / , '' )
6
+ SLUG . sub ( /Type\z / , '' )
7
7
end
8
8
9
9
def fast
You can’t perform that action at this time.
0 commit comments