Sha256: cd5544ca76fec05eb8069e4c861d64760288a1f73fe38f481f223ecadf35a7f1

Contents?: true

Size: 1.39 KB

Versions: 8

Compression:

Stored size: 1.39 KB

Contents

#  Phusion Passenger - http://www.modrails.com/
#  Copyright (C) 2008  Phusion
#
#  Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; version 2 of the License.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License along
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

class Object # :nodoc:
	@@benchmark_results = {}

	def b!(name)
		time1 = Time.now
		begin
			yield
		ensure
			time2 = Time.now
			@@benchmark_results[name] = 0 unless @@benchmark_results.has_key?(name)
			@@benchmark_results[name] += time2 - time1
		end 
	end

	def benchmark_report(main = nil)
		total = 0
		if main.nil?
			@@benchmark_results.each_value do |time|
				total += time
			end
		else
			total = @@benchmark_results[main]
		end
		@@benchmark_results.each_pair do |name, time|
			printf "%-12s: %.4f (%.2f%%)\n", name, time, time / total * 100
		end
		printf "-- Total: %.4f\n", total
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
passenger-2.0.1 lib/passenger/simple_benchmarking.rb
passenger-2.0.3 lib/passenger/simple_benchmarking.rb
passenger-2.0.4 lib/passenger/simple_benchmarking.rb
passenger-2.0.2 lib/passenger/simple_benchmarking.rb
passenger-2.0.6 lib/passenger/simple_benchmarking.rb
passenger-2.1.2 lib/phusion_passenger/simple_benchmarking.rb
passenger-2.0.5 lib/passenger/simple_benchmarking.rb
passenger-2.1.3 lib/phusion_passenger/simple_benchmarking.rb