Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git://github.com/rdp/ruby-prof

Conflicts:
	CHANGES
	ext/ruby_prof/measure_process_time.h
	lib/ruby-prof.rb
	ruby-prof.gemspec
  • Loading branch information...
commit ae2c5ef90981d9f37cd90c9ea1df7655fc3f8be1 2 parents ea8c77d + 83cc0b6
@goncalossilva goncalossilva authored
View
28 CHANGES
@@ -1,5 +1,28 @@
-<<<<<<< HEAD
-=======
+0.10.5
+=======================
+1.8.6 compat for -v command (bug fix)
+
+0.10.4
+=======================
+Faster load time for ruby-prof itself.
+
+0.10.3
+=======================
+Can cleanly load before rubygems now.
+
+0.10.2
+=======================
+Fix for 1.9.2, os x for latest commits (thanks skaes!)
+
+0.10.1
+=======================
+Fix bug in linux wall time, also load with only relative paths so that you can use it to benchmark rubygems startup overhead,
+itself.
+
+0.10.0
+=======================
+Some rdoc changes, for linux wall time attempt to use higher granularity (thanks to all the contributors for this round!)
+
0.9.2
=======================
Make graphviz work on 1.8.6
@@ -9,7 +32,6 @@ roll back some 1.9.2 optimizations until I can figure out what caused them.
=======================
Add a graphviz output
->>>>>>> 31a7a37051007c8019fe1882d73e16275c2766b8
0.9.0
=======================
* measurements for recursive methods are now correct
View
42 README.rdoc
@@ -12,7 +12,6 @@ ruby-prof is a fast code profiler for Ruby. Its features include:
- Call tree profiles - outputs results in the calltree format suitable for the KCacheGrind profiling tool.
* Threads - supports profiling multiple threads simultaneously
-
== Requirements
ruby-prof requires Ruby 1.8.4 or higher.
@@ -21,7 +20,7 @@ If you are running Linux or Unix you'll need a C compiler so the extension
can be compiled when it is installed.
If you are running Windows, then you may need to install the
-Windows specific RubyGem which includes an already built extension (see below).
+Windows specific RubyGem which includes an already built extension (see Install section).
== Install
@@ -30,11 +29,11 @@ The easiest way to install ruby-prof is by using Ruby Gems. To install:
gem install ruby-prof
If you on windows mswin [not mingw] (check via ruby -v) and
-don't have an MSVC compiler, please install v0.7.3 which
+don't have an MSVC compiler, please install v0.8.1 which
has a prebuilt binary
-C:> gem install ruby-prof -v0.7.3
+C:> gem install ruby-prof -v0.8.1
-If you're on mingw, please install the devkit first, then install the latest version (gem install ruby-prof).
+If you're on mingw, please install the devkit first, then install the latest gem version (via gem install ruby-prof).
== Usage
@@ -79,7 +78,7 @@ to profile:
# Print a graph profile to text
printer = RubyProf::GraphPrinter.new(result)
- printer.print(STDOUT, 0)
+ printer.print(STDOUT, {})
Starting with the 0.6.1 release, ruby-prof also supports pausing and resuming
profiling runs.
@@ -110,18 +109,14 @@ has not yet started. In addition, resume can also take a block:
With this usage, resume will automatically call pause at the
end of the block.
-
=== require unprof
The third way of using ruby-prof is by requiring unprof.rb:
require 'unprof'
-This will start profiling immediately and will output the results
-using a flat profile report.
-
-This method is provided for backwards compatibility. Using the
-ruby-prof command provides more flexibility.
+This will start profiling immediately at that point and will output the results
+using a flat profile report when the process ends.
== Method Elimination
@@ -145,6 +140,22 @@ the name of a file containing a list of regular expressions (line separated text
After eliminating methods the resulting profile will appear exactly as if those methods
had been inlined at their call sites.
+== Benchmarking full load time including rubygems startup cost ==
+
+If you want to get a more accurate measurement of what takes all of a gem's bin/xxx
+command to load, you may want to also measure rubygems' startup penalty.
+You can do this by calling into bin/ruby-prof directly, ex:
+
+$ gem which ruby-prof
+ g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/lib/ruby-prof.rb
+
+now run it thus (substitute lib/ruby-prof.rb with bin/ruby-prof):
+
+$ ruby g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/bin/ruby-prof g:\192\bin\some_installed_gem_command
+
+or
+
+$ ruby g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/bin/ruby-prof ./some_file_that_does_a_require_rubygems_at_the_beginning.rb
== Profiling Tests
@@ -230,6 +241,7 @@ ruby-prof can generate a number of different reports:
* HTML Graph Reports
* Call graphs
* Call stack reports
+* More!
Flat profiles show the overall time spent in each method. They
are a good of quickly identifying which methods take the most time.
@@ -276,6 +288,7 @@ Reports are created by printers. Supported printers include:
* RubyProf::CallTreePrinter - Creates a call tree report compatible with KCachegrind.
* RubyProf::CallStackPrinter - Creates a HTML visualization of the Ruby stack
* RubyProf::MultiPrinter - Uses the other printers to create several reports in one profiling run
+* More!
To use a printer:
@@ -427,7 +440,8 @@ profiled. Most programs will run approximately twice as slow
while highly recursive programs (like the fibonacci series test)
will run three times slower.
-Because of some threading difficulties in 1.9, it currently runs a bit slower there.
+Because of some threading difficulties in 1.9, it currently runs a
+bit slower there, as well.
http://www.ruby-forum.com/topic/201329
== License
@@ -437,3 +451,5 @@ See LICENSE for license information.
== Development
Code is located at http://github.com/rdp/ruby-prof
+
+Google group/mailing list: http://groups.google.com/group/ruby-prof
View
75 Rakefile
@@ -4,71 +4,17 @@ require 'rake/rdoctask'
require 'rake/testtask'
require 'date'
-# ------- Version ----
-# Read version from header file
-version_header = File.read('ext/ruby_prof/version.h')
-match = version_header.match(/RUBY_PROF_VERSION\s*["](\d.+)["]/)
-raise(RuntimeError, "Could not determine RUBY_PROF_VERSION") if not match
-RUBY_PROF_VERSION = match[1]
+# to release a version of ruby-prof, do a git tag, then rake cleanr default and publish that
+# git tag 0.10.1
+# git push origin 0.10.1
+# rake cleanr default
+# gem push pkg/ruby-prof-0.10.1.gem
+default_spec = eval File.read(File.expand_path('../ruby-prof.gemspec', __FILE__))
-# ------- Default Package ----------
-FILES = FileList[
- 'Rakefile',
- 'README.rdoc',
- 'LICENSE',
- 'CHANGES',
- 'bin/*',
- 'doc/**/*',
- 'examples/*',
- 'ext/ruby_prof/*.c',
- 'ext/ruby_prof/*.h',
- 'ext/ruby_prof/mingw/Rakefile',
- 'ext/ruby_prof/mingw/build.rake',
- 'ext/vc/*.sln',
- 'ext/vc/*.vcproj',
- 'lib/**/*',
- 'rails/**/*',
- 'test/*'
-]
-
-# Default GEM Specification
-default_spec = Gem::Specification.new do |spec|
- spec.name = "ruby-prof"
-
- spec.homepage = "http://rubyforge.org/projects/ruby-prof/"
- spec.summary = "Fast Ruby profiler"
- spec.description = <<-EOF
-ruby-prof is a fast code profiler for Ruby. It is a C extension and
-therefore is many times faster than the standard Ruby profiler. It
-supports both flat and graph profiles. For each method, graph profiles
-show how long the method ran, which methods called it and which
-methods it called. RubyProf generate both text and html and can output
-it to standard out or to a file.
-EOF
-
- spec.version = RUBY_PROF_VERSION
-
- spec.author = "Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes"
- spec.email = "shugo@ruby-lang.org, cfis@savagexi.com, rogerdpack@gmail.com, skaes@railsexpress.de"
- spec.platform = Gem::Platform::RUBY
- spec.require_path = "lib"
- spec.bindir = "bin"
- spec.executables = ["ruby-prof"]
- spec.extensions = ["ext/ruby_prof/extconf.rb"]
- spec.files = FILES.to_a
- spec.test_files = Dir["test/test_*.rb"]
- spec.required_ruby_version = '>= 1.8.4'
- spec.date = DateTime.now
- spec.rubyforge_project = 'ruby-prof'
- spec.add_development_dependency 'os'
- spec.add_development_dependency 'rake-compiler'
-
-end
-
-
-desc 'build native .gem files -- use like "native_gems clobber cross native gem"--for non native gem creation use "native_gems clobber" then "clean gem"'
+desc 'deprecated--build native .gem files -- use like "native_gems clobber cross native gem"--for non native gem creation use "native_gems clobber" then "clean gem"'
task :native_gems do
+ # we don't do cross compiler anymore, now that mingw has devkit
ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
require 'rake/extensiontask'
Rake::ExtensionTask.new('ruby_prof', default_spec) do |ext|
@@ -125,7 +71,7 @@ task :build do
system(Gem.ruby + " extconf.rb")
system("make clean")
end
- system("make")
+ raise 'make failed' unless system("make")
FileUtils.cp 'ruby_prof.so', '../../lib' if File.exist? 'lib/ruby_prof.so'
FileUtils.cp 'ruby_prof.bundle', '../../lib' if File.exist? 'lib/ruby_prof.bundle'
end
@@ -133,8 +79,7 @@ end
desc 'clean stuff'
task :cleanr do
- FileUtils.rm 'lib/ruby_prof.so' if File.exist? 'lib/ruby_prof.so'
- FileUtils.rm 'lib/ruby_prof.bundle' if File.exist? 'lib/ruby_prof.bundle'
+ Dir['**/*.{so,bundle}'].each{|f| File.delete f}
Dir.chdir('ext/ruby_prof') do
if File.exist? 'Makefile'
system("make clean")
View
91 bin/ruby-prof
@@ -8,46 +8,14 @@
#
# ruby_prof [options] <script.rb> [--] [script-options]"
#
-# Options:
-# -p, --printer=printer Select a printer:
-# flat - Prints a flat profile as text (default).
-# flat_with_line_numbers - Above, with line numbers
-# graph - Prints a graph profile as text.
-# graph_html - Prints a graph profile as html.
-# call_tree - format for KCacheGrind
-# call_stack - prints a HTML visualization of the call tree
-# dot - Prints a graph profile as a dot file
-# -f, --file=path Output results to a file instead of standard out.
-# -m, --min_percent=min_percent The minimum percent a method must take before ',
-# being included in output reports. Should be an
-# integer between 1 and 100. 0 means all methods are printed.
-# --mode=measure_mode Select a measurement mode:
-# process - Use process time (default).
-# wall - Use wall time.
-# cpu - Use the CPU clock counter
-# (only supported on Pentium and PowerPCs).
-# allocations - Tracks object allocations
-# (requires a patched Ruby interpreter).
-# memory - Tracks total memory size
-# (requires a patched Ruby interpreter).
-# gc_runs - Tracks number of garbage collection runs
-# (requires a patched Ruby interpreter).
-# gc_time - Tracks time spent doing garbage collection
-# (requires a patched Ruby interpreter).
-# --replace-progname Replace $0 when loading the .rb files.
-# --specialized-instruction Turn on specialized instruction.
-# -h, --help Show help message
-# --version Show version
-# -v Show version, set $VERBOSE to true, run file
-# -d Set $DEBUG to true
-#
+# Various options:
+# run "$ ruby-prof --help" to see them
#
# See also: {flat profiles}[link:files/examples/flat_txt.html], {graph profiles}[link:files/examples/graph_txt.html], {html graph profiles}[link:files/examples/graph_html.html]
-#
require 'ostruct'
require 'optparse'
-require 'ruby-prof'
+require File.dirname(__FILE__) + "/../lib/ruby-prof"
options = OpenStruct.new
options.measure_mode = RubyProf::PROCESS_TIME
@@ -59,7 +27,7 @@ options.specialized_instruction = false
opts = OptionParser.new do |opts|
opts.banner = "ruby_prof #{RubyProf::VERSION}\n" +
- "Usage: ruby_prof [options] <script.rb> [--] [script-options]"
+ "Usage: ruby-prof [options] <script.rb> [--] [profiled-script-command-line-options]"
opts.separator ""
opts.separator "Options:"
@@ -157,15 +125,34 @@ opts = OptionParser.new do |opts|
exit
end
- opts.on("-v","Show version, set $VERBOSE to true, profile script") do
- puts "ruby_prof " + RubyProf::VERSION
- puts "ruby " + RUBY_DESCRIPTION
- $VERBOSE= true
+ opts.on("-v","Show version, set $VERBOSE to true, profile script if option given") do
+ puts "ruby version: " + [RUBY_PATCHLEVEL, RUBY_PLATFORM, RUBY_VERSION].join(' ')
+ $VERBOSE = true
end
opts.on("-d", "Set $DEBUG to true") do
$DEBUG = true
end
+
+ opts.on('-R lib', '--require-noprof lib', 'require a specific library (not profiled)') do |lib|
+ options.pre_libs ||= []
+ options.pre_libs << lib
+ end
+
+ opts.on('-E code', '--eval-noprof code', 'execute the ruby statements (not profiled)') do |code|
+ options.pre_exec ||= []
+ options.pre_exec << code
+ end
+
+ opts.on('-r lib', '--require lib', 'require a specific library') do |lib|
+ options.libs ||= []
+ options.libs << lib
+ end
+
+ opts.on('-e code', '--eval', 'execute the ruby statements') do |code|
+ options.exec ||= []
+ options.exec << code
+ end
end
begin
@@ -179,7 +166,7 @@ rescue OptionParser::InvalidOption, OptionParser::InvalidArgument,
end
# Make sure the user specified at least one file
-if ARGV.length < 1
+if ARGV.length < 1 and not options.exec
puts opts
puts ""
puts "Must specify a script to run"
@@ -229,8 +216,28 @@ if options.replace_prog_name
$0 = File.expand_path(script)
end
+if options.pre_libs
+ options.pre_libs.each { |l| require l }
+end
+
+if options.pre_exec
+ options.pre_exec.each { |c| eval c }
+end
+
+# do not pollute profiling report with OpenStruct#libs
+ol = options.libs
+oe = options.exec
+
# Start profiling
RubyProf.start
+if ol
+ ol.each { |l| require l }
+end
+
+if oe
+ oe.each { |c| eval c }
+end
+
# Load the script
-load script
+load script if script
View
16 ext/ruby_prof/extconf.rb
@@ -33,6 +33,20 @@ def add_define(name, value = nil)
$defs.push("-D#{name}")
end
end
-
+require 'rubygems'
+unless Gem.win_platform? || RUBY_PLATFORM =~ /darwin/
+ $LDFLAGS += " -lrt" # for clock_gettime
+end
add_define("RUBY_VERSION", RUBY_VERSION.gsub('.', ''))
+
+# for ruby 1.9, determine whether threads inherit trace flags (latest 1.9.2 works correctly)
+if RUBY_VERSION > "1.9"
+ require 'set'
+ threads = Set.new
+ set_trace_func lambda { |*args| threads << Thread.current.object_id }
+ Thread.new{1}.join
+ set_trace_func nil
+ add_define("THREADS_INHERIT_EVENT_FLAGS", (threads.size == 2) ? "1" : "0")
+end
+
create_makefile("ruby_prof")
View
2  ext/ruby_prof/ruby_prof.c
@@ -1160,7 +1160,7 @@ prof_event_hook(rb_event_flag_t event, NODE *node, VALUE self, ID mid, VALUE kla
thread = rb_thread_current();
thread_id = rb_obj_id(thread);
- # if RUBY_VERSION >= 191
+ # if RUBY_VERSION >= 191 && THREADS_INHERIT_EVENT_FLAGS==0
/* ensure that new threads are hooked [sigh] (bug in core) */
prof_remove_hook();
prof_install_hook();
View
6 ext/ruby_prof/version.h
@@ -1,4 +1,4 @@
-#define RUBY_PROF_VERSION "0.9.2" // for easy parsing from rake files
+#define RUBY_PROF_VERSION "0.10.5" // for easy parsing from rake files
#define RUBY_PROF_VERSION_MAJ 0
-#define RUBY_PROF_VERSION_MIN 9
-#define RUBY_PROF_VERSION_MIC 2
+#define RUBY_PROF_VERSION_MIN 10
+#define RUBY_PROF_VERSION_MIC 5
View
57 lib/ruby-prof.rb
@@ -1,32 +1,35 @@
-# require the .so file...
-
-me = File.dirname(__FILE__) + '/'
-begin
- # fat binaries
- require "#{me}/#{RUBY_VERSION[0..2]}/ruby_prof"
-rescue Exception
- require "#{me}/../ext/ruby_prof/ruby_prof"
-end
-
-require "ruby-prof/result"
-require "ruby-prof/method_info"
-require "ruby-prof/call_info"
-require "ruby-prof/aggregate_call_info"
-require "ruby-prof/flat_printer"
-require "ruby-prof/flat_printer_with_line_numbers"
-require "ruby-prof/graph_printer"
-require "ruby-prof/graph_html_printer"
-require "ruby-prof/graph_yaml_printer"
-require "ruby-prof/call_tree_printer"
-require "ruby-prof/call_stack_printer"
-require "ruby-prof/multi_printer"
-require "ruby-prof/dot_printer"
-require "ruby-prof/symbol_to_proc" # for 1.8's benefit
-require "ruby-prof/rack"
-#require "ruby-prof/result"
+# require the .so file...
+require File.dirname(__FILE__) + "/../ext/ruby_prof/ruby_prof"
module RubyProf
- # See if the user specified the clock mode via
+
+ if RUBY_VERSION < '1.8.7'
+ require File.dirname(__FILE__) + '/ruby-prof/symbol_to_proc'
+ end
+
+ def self.camelcase(phrase)
+ ('_' + phrase).gsub(/_([a-z])/){|b| b[1..1].upcase}
+ end
+
+ lib_dir = File.dirname(__FILE__) + '/ruby-prof/'
+
+ for file in ['abstract_printer', 'aggregate_call_info', 'flat_printer', 'flat_printer_with_line_numbers',
+ 'graph_printer', 'graph_html_printer', 'call_tree_printer', 'call_stack_printer', 'multi_printer', 'dot_printer']
+ autoload camelcase(file), lib_dir + file
+ end
+
+ # A few need to be loaded manually their classes were already defined by the .so file so autoload won't work for them.
+ # plus we need them anyway
+ for name in ['result', 'method_info', 'call_info']
+ require lib_dir + name
+ end
+
+ require File.dirname(__FILE__) + '/ruby-prof/rack' # do we even need to load this every time?
+
+ # we don't require unprof.rb, as well, purposefully
+
+
+ # Checks if the user specified the clock mode via
# the RUBY_PROF_MEASURE_MODE environment variable
def self.figure_measure_mode
case ENV["RUBY_PROF_MEASURE_MODE"]
View
28 lib/ruby-prof/call_stack_printer.rb
@@ -1,4 +1,3 @@
-require 'ruby-prof/abstract_printer'
require 'erb'
require 'fileutils'
@@ -11,6 +10,33 @@ def initialize(result)
super(result)
end
+ # Specify print options.
+ #
+ # options - Hash table
+ # :min_percent - Number 0 to 100 that specifes the minimum
+ # %self (the methods self time divided by the
+ # overall total time) that a method must take
+ # for it to be printed out in the report.
+ # Default value is 0.
+ #
+ # :print_file - True or false. Specifies if a method's source
+ # file should be printed. Default value if false.
+ #
+ # :threshold - a float from 0 to 100 that sets the threshold of
+ # results displayed.
+ # Default value is 1.0
+ #
+ # :title - a String to overide the default "ruby-prof call tree"
+ # title of the report.
+ #
+ # :expansion - a float from 0 to 100 that sets the threshold of
+ # results that are expanded, if the percent_total
+ # exceeds it.
+ # Default value is 10.0
+ #
+ # :application - a String to overide the name of the application,
+ # as it appears on the report.
+ #
def print(output = STDOUT, options = {})
@output = output
setup_options(options)
View
13 lib/ruby-prof/call_tree_printer.rb
@@ -1,10 +1,21 @@
-require 'ruby-prof/abstract_printer'
module RubyProf
# Generate profiling information in calltree format
# for use by kcachegrind and similar tools.
class CallTreePrinter < AbstractPrinter
+ # Specify print options.
+ #
+ # options - Hash table
+ # :min_percent - Number 0 to 100 that specifes the minimum
+ # %self (the methods self time divided by the
+ # overall total time) that a method must take
+ # for it to be printed out in the report.
+ # Default value is 0.
+ #
+ # :print_file - True or false. Specifies if a method's source
+ # file should be printed. Default value if false.
+ #
def print(output = STDOUT, options = {})
@output = output
setup_options(options)
View
1  lib/ruby-prof/dot_printer.rb
@@ -1,5 +1,4 @@
require 'set'
-require 'ruby-prof/abstract_printer'
module RubyProf
# Generates a graphviz graph in dot format.
View
3  lib/ruby-prof/flat_printer.rb
@@ -1,4 +1,3 @@
-require 'ruby-prof/abstract_printer'
module RubyProf
# Generates flat[link:files/examples/flat_txt.html] profile reports as text.
@@ -9,7 +8,7 @@ module RubyProf
# end
#
# printer = RubyProf::FlatPrinter.new(result)
- # printer.print(STDOUT, 0)
+ # printer.print(STDOUT, {})
#
class FlatPrinter < AbstractPrinter
# Print a flat profile report to the provided output.
View
5 lib/ruby-prof/flat_printer_with_line_numbers.rb
@@ -1,5 +1,4 @@
-require 'ruby-prof/abstract_printer'
-require 'pathname'
+
module RubyProf
# Generates flat[link:files/examples/flat_txt.html] profile reports as text.
# To use the flat printer with line numbers:
@@ -9,7 +8,7 @@ module RubyProf
# end
#
# printer = RubyProf::FlatPrinterWithLineNumbers.new(result)
- # printer.print(STDOUT, 0)
+ # printer.print(STDOUT, {})
#
class FlatPrinterWithLineNumbers < FlatPrinter
View
8 lib/ruby-prof/graph_html_printer.rb
@@ -1,4 +1,3 @@
-require 'ruby-prof/abstract_printer'
require 'erb'
module RubyProf
@@ -43,6 +42,13 @@ def initialize(result)
# options - Hash of print options. See #setup_options
# for more information.
#
+ # unique options are:
+ # :filename - specify a file to use that contains the ERB
+ # template to use, instead of the built-in self.template
+ #
+ # :template - specify an ERB template to use, instead of the
+ # built-in self.template
+ #
def print(output = STDOUT, options = {})
@output = output
setup_options(options)
View
3  lib/ruby-prof/graph_printer.rb
@@ -1,4 +1,3 @@
-require 'ruby-prof/abstract_printer'
module RubyProf
# Generates graph[link:files/examples/graph_txt.html] profile reports as text.
@@ -9,7 +8,7 @@ module RubyProf
# end
#
# printer = RubyProf::GraphPrinter.new(result, 5)
- # printer.print(STDOUT, 0)
+ # printer.print(STDOUT, {})
#
# The constructor takes two arguments. See the README
View
12 lib/ruby-prof/rack.rb
@@ -1,3 +1,4 @@
+
module Rack
class RubyProf
def initialize(app)
@@ -13,13 +14,14 @@ def call(env)
result
end
- def print
- printers = {::RubyProf::FlatPrinter => 'c:/temp/profile.txt',
- ::RubyProf::GraphHtmlPrinter => 'c:/temp/profile.html'}
+ def print(data)
+ require 'tmpdir' # late require so we load on demand only
+ printers = {::RubyProf::FlatPrinter => ::File.join(Dir.tmpdir, 'profile.txt'),
+ ::RubyProf::GraphHtmlPrinter => ::File.join(Dir.tmpdir, 'profile.html')}
printers.each do |printer_klass, file_name|
- printer = printer_klass.new(result)
- ::File.open(file_name, 'wb') do |file|
+ printer = printer_klass.new(data)
+ ::File.open(file_name, 'wb') do |file|
printer.print(file, :min_percent => 0.00000001 )
end
end
View
60 ruby-prof.gemspec
@@ -1,56 +1,56 @@
-version_header = File.read('ext/ruby_prof/version.h')
+# -*- encoding: utf-8 -*-
+
+# Read version from header file
+version_header = File.read(File.expand_path('../ext/ruby_prof/version.h', __FILE__))
match = version_header.match(/RUBY_PROF_VERSION\s*["](\d.+)["]/)
raise(RuntimeError, "Could not determine RUBY_PROF_VERSION") if not match
-version = match[1]
-
-FILES = Dir[
- 'Rakefile',
- 'README',
- 'LICENSE',
- 'CHANGES',
- 'bin/*',
- 'doc/**/*',
- 'examples/*',
- 'ext/ruby_prof/*.c',
- 'ext/ruby_prof/*.h',
- 'ext/ruby_prof/mingw/Rakefile',
- 'ext/ruby_prof/mingw/build.rake',
- 'ext/vc/*.sln',
- 'ext/vc/*.vcproj',
- 'lib/**/*',
- 'rails/**/*',
- 'test/*'
-]
+RUBY_PROF_VERSION = match[1]
Gem::Specification.new do |spec|
spec.name = "ruby-prof"
-
+
spec.homepage = "http://rubyforge.org/projects/ruby-prof/"
spec.summary = "Fast Ruby profiler"
spec.description = <<-EOF
ruby-prof is a fast code profiler for Ruby. It is a C extension and
therefore is many times faster than the standard Ruby profiler. It
supports both flat and graph profiles. For each method, graph profiles
-show how long the method ran, which methods called it and which
+show how long the method ran, which methods called it and which
methods it called. RubyProf generate both text and html and can output
it to standard out or to a file.
EOF
- spec.version = version
+ spec.version = RUBY_PROF_VERSION
- spec.author = "Shugo Maeda, Charlie Savage, Roger Pack"
- spec.email = "shugo@ruby-lang.org, cfis@savagexi.com, rogerdpack@gmail.com"
+ spec.author = "Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes"
+ spec.email = "shugo@ruby-lang.org, cfis@savagexi.com, rogerdpack@gmail.com, skaes@railsexpress.de"
spec.platform = Gem::Platform::RUBY
- spec.require_path = "lib"
+ spec.require_path = "lib"
spec.bindir = "bin"
spec.executables = ["ruby-prof"]
spec.extensions = ["ext/ruby_prof/extconf.rb"]
- spec.files = FILES.to_a
+ spec.files = Dir['Rakefile',
+ 'README.rdoc',
+ 'LICENSE',
+ 'CHANGES',
+ 'bin/*',
+ 'doc/**/*',
+ 'examples/*',
+ 'ext/ruby_prof/*.c',
+ 'ext/ruby_prof/*.h',
+ 'ext/ruby_prof/mingw/Rakefile',
+ 'ext/ruby_prof/mingw/build.rake',
+ 'ext/vc/*.sln',
+ 'ext/vc/*.vcproj',
+ 'lib/**/*',
+ 'rails/**/*',
+ 'test/*']
+
spec.test_files = Dir["test/test_*.rb"]
- spec.required_ruby_version = '>= 1.8.6'
+ spec.required_ruby_version = '>= 1.8.4'
spec.date = DateTime.now
spec.rubyforge_project = 'ruby-prof'
spec.add_development_dependency 'os'
spec.add_development_dependency 'rake-compiler'
-
+
end
View
2  test/module_test.rb
@@ -38,7 +38,7 @@ def test_nested_modules
# these methods should be in there... (hard to tell order though).
for name in ['ModuleTest#test_nested_modules','Bar#hello','Kernel#sleep','<Module::Bar>#hello','<Module::Foo>#hello']
- assert methods.map(&:full_name).include? name
+ assert methods.map(&:full_name).include?( name )
end
end
end
View
20 test/printers_test.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
require 'test/unit'
require 'ruby-prof'
-require 'prime'
+require File.dirname(__FILE__) + '/prime'
require 'stringio'
require 'fileutils'
require 'rubygems'
@@ -90,18 +90,12 @@ def test_flat_string_with_numbers
assert_match(/called from/, output)
# should combine common parents
- # lodo remove...
- #if RUBY_VERSION < '1.9'
- #require 'ruby-debug'
- #debugger
- #print output
- assert_equal(3, output.scan(/Object#is_prime/).length) # failing this is prolly a 1.9.2 core bug
- #else
- # # 1.9
- # require 'ruby-debug'
- # debugger
- # assert_equal(2, output.scan(/Object#is_prime/).length)
- #end
+ if RUBY_VERSION < '1.9'
+ assert_equal(3, output.scan(/Object#is_prime/).length)
+ else
+ # 1.9 inlines it's Fixnum#- so we don't see as many
+ assert_equal(2, output.scan(/Object#is_prime/).length)
+ end
assert_no_match(/\.\/test\/prime.rb/, output) # don't use relative paths
end
View
2  test/stack_printer_test.rb
@@ -46,7 +46,7 @@ def test_stack_can_be_printed
assert file_contents =~ /Thread: (\d+) \(100\.00% ~ ([.0-9]+)\)/
actual_time = $2.to_f
difference = (expected_time-actual_time).abs
- assert difference<0.001 # less than 1 ms
+ assert difference < 0.01 # less than 1 ms
end
def test_method_elimination
Please sign in to comment.
Something went wrong with that request. Please try again.