performance/externals.rb in identity_cache-0.5.1 vs performance/externals.rb in identity_cache-1.0.0

- old
+ new

@@ -1,16 +1,17 @@ +# frozen_string_literal: true require 'rubygems' require 'benchmark' require 'ruby-prof' require_relative 'cache_runner' RUNS = 1000 RubyProf.measure_mode = RubyProf::CPU_TIME -EXTERNALS = {"Memcache" => ["MemCache#set", "MemCache#get"], - "Database" => ["Mysql2::Client#query"]} +EXTERNALS = { "Memcache" => ["MemCache#set", "MemCache#get"], + "Database" => ["Mysql2::Client#query"] } def run(obj) obj.prepare RubyProf.start obj.run @@ -24,10 +25,10 @@ def count_externals(results) count = {} results.split(/\n/).each do |line| fields = line.split - if ext = EXTERNALS.detect { |e| e[1].any? { |method| method == fields[-1] } } + if (ext = EXTERNALS.detect { |e| e[1].any? { |method| method == fields[-1] } }) count[ext[0]] ||= 0 count[ext[0]] += fields[-2].to_i end end EXTERNALS.each do |ext|