# File lib/railsbench/perf_info.rb, line 69 def initialize(file) @entries = [] file.each_line do |line| case line when /^.*perf_([a-zA-Z.]+)\s+(\d+)\s+(.*)$/ @iterations = $2.to_i @options = $3 when /\s+user\s+system\s+total\s+real/ @entries << PerfEntry.new when /^(.*)\s+([\d\.]+)\s+([\d\.]+)\s+([\d\.]+)\s+\(\s*([\d\.]+)\s*\)$/ key, time = $1.strip, $5.to_f if key == "loading environment" @entries.last.load_time = time else @entries.last.keys << key @entries.last.timings[key] = time end when /^GC.collections=(\d+), GC.time=([\d\.]+)$/ @entries.last.gc_calls, @entries.last.gc_time = [$1.to_i,$2.to_f] @gc_stats = true end end @entries.each{ |e| e.total_time = e.timings.values.sum } @keys = @entries.first.keys @runs = @entries.length if @keys.length == 1 && @keys[0] =~ /\((\d+) urls\)$/ @requests_per_key = $1.to_i else @requests_per_key = 1 end @request_count = @iterations * @keys.length * @requests_per_key @timings = PerfSummaries.inject({}){ |hash, method| hash[method] = Hash.new; hash } @keys.each do |k| a = @entries.map{|e| e.timings[k]} [:min, :max, :mean].each do |method| @timings[method][k] = a.send(method) end mean = @timings[:mean][k] stddev = @timings[:stddev][k] = a.send(:stddev, mean) @timings[:stddev_percentage][k] = stddev_percentage(stddev, mean) end PerfAttributes.each do |attr| next if attr.to_s =~ /^gc_/ and !gc_stats? a = @entries.map{|e| e.send attr} [:min, :max, :mean].each do |method| instance_variable_set "@#{attr}_#{method}", (a.send method) end mean = instance_variable_get "@#{attr}_mean" stddev = instance_variable_set "@#{attr}_stddev", (a.send :stddev, mean) instance_variable_set "@#{attr}_stddev_percentage", stddev_percentage(stddev, mean) end end
Generated with the Darkfish Rdoc Generator 2.