Actions
Patch #28939
closedreplace regexp with casecmp
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Performance
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Description
require 'benchmark/ips' Benchmark.ips do |x| x.report('casecmp') { 'PostgreSql'.casecmp('postgresql') == 0 } x.report('match') { 'PostgreSql' =~ /postgresql/i } x.report('match?') { 'PostgreSql'.match? /postgresql/i } x.compare! end
Comparsion: casecmp: 4218477.8 i/s match?: 3025829.3 i/s - 1.39x slower match: 2222223.1 i/s - 1.90x slower
Files
Related issues
Updated by Pavel Rosický over 6 years ago
- File nested_set.patch nested_set.patch added
Updated by Go MAEDA over 6 years ago
The proposed patch does not work for MySQL adapter because its name is "Mysql2". I think using exact match against adapter names is not a good solution.
irb(main):001:0> ActiveRecord::Base.connection.adapter_name => "Mysql2"
Updated by Pavel Rosický over 6 years ago
- Status changed from New to Resolved
ah, sorry. I totaly forgot about this case. I used match? insted in
http://www.redmine.org/issues/28940
so the behaviour won't be changed. Closing this one
Updated by Go MAEDA over 6 years ago
- Related to Patch #28940: Use Regexp#match? to reduce allocations of MatchData object added
Updated by Go MAEDA over 6 years ago
- Status changed from Resolved to Closed
Pavel Rosický wrote:
I used match? insted in
http://www.redmine.org/issues/28940
Closing this issue because #28940 covers this improvement. Thank you.
Actions