aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/hot_compatibility_test.rb
diff options
context:
space:
mode:
authorMindaugas Mozūras <mindaugas.mozuras@gmail.com>2014-06-15 21:47:37 +0300
committerMindaugas Mozūras <mindaugas.mozuras@gmail.com>2014-06-15 22:26:15 +0300
commite3123815898145888fe84f053b14f5cfc33c1684 (patch)
treed7dd4a2bd3582d86bb6f80ff86255c107889cbee /activerecord/test/cases/hot_compatibility_test.rb
parent3268a04e991994e37515873339e120deba1ce144 (diff)
downloadrails-e3123815898145888fe84f053b14f5cfc33c1684.tar.gz
rails-e3123815898145888fe84f053b14f5cfc33c1684.tar.bz2
rails-e3123815898145888fe84f053b14f5cfc33c1684.zip
Change Http::Cache::SPECIAL_KEYS from Array to Set
Slightly improves performance, for example, a simple benchmark: ```ruby require 'benchmark/ips' require 'set' SPECIAL_KEYS = %w[extras no-cache max-age public must-revalidate] SPECIAL_KEYS_SET = Set.new(SPECIAL_KEYS) directive = 'must-revalidate' Benchmark.ips do |x| x.report('array') { SPECIAL_KEYS.include?(directive) } x.report('set') { SPECIAL_KEYS_SET.include?(directive) } end ``` Output: ``` ------------------------------------- array 67926 i/100ms set 74054 i/100ms ------------------------------------- array 2318423.4 (±2.8%) i/s - 11615346 in 5.014899s set 3387981.8 (±4.7%) i/s - 16958366 in 5.019355s ```
Diffstat (limited to 'activerecord/test/cases/hot_compatibility_test.rb')
0 files changed, 0 insertions, 0 deletions