Sha256: de9703a55c901b3790f1cb713fc47181071cc3ba531024a5665270798883d547
Contents?: true
Size: 975 Bytes
Versions: 1
Compression:
Stored size: 975 Bytes
Contents
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"]} def run(obj) obj.prepare RubyProf.start obj.run result = RubyProf.stop puts "Results for #{obj.class.name}:" results = StringIO.new printer = RubyProf::FlatPrinter.new(result) printer.print(results) count_externals(results.string) end 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] } } count[ext[0]] ||= 0 count[ext[0]] += fields[-2].to_i end end EXTERNALS.each do |ext| puts "#{ext[0]}: #{count[ext[0]] || 0}" end end create_database(RUNS) run(FindRunner.new(RUNS)) run(FetchHitRunner.new(RUNS)) run(FetchMissRunner.new(RUNS))
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
identity_cache-0.0.3 | performance/externals.rb |