ruby_prof_helper 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/ruby_prof_helper.rb +36 -0
  2. metadata +64 -0
@@ -0,0 +1,36 @@
1
+ # -*- encoding : utf-8 -*-
2
+ DEFAULT_RUBY_PROF_OPTIONS = {
3
+ filename: 'callgraph.html',
4
+ printer: RubyProf::GraphHtmlPrinter
5
+ }
6
+
7
+ KCACHEGRIND_RUBY_PROF_OPTIONS = {
8
+ filename: 'callgrind.trace',
9
+ printer: RubyProf::CallTreePrinter
10
+ }
11
+
12
+ def ruby_prof(options = DEFAULT_RUBY_PROF_OPTIONS)
13
+ RubyProf.start
14
+ options = DEFAULT_RUBY_PROF_OPTIONS.merge options
15
+ yield
16
+ ensure
17
+ callgraph = RubyProf.stop
18
+
19
+ callgraph.eliminate_methods!([
20
+ /IRB::Irb#signal_status/,
21
+ /Fixnum#>/,
22
+ /Arel::/,
23
+ /Array#each/,
24
+ /Array#map/,
25
+ /Enumerable#reduce/,
26
+ /Enumerable#map/,
27
+ /Enumerable#collect/,
28
+ /Array#collect/,
29
+ /Array#select/
30
+ ])
31
+
32
+ printer = options.fetch(:printer)
33
+ filename = options.fetch(:filename)
34
+
35
+ printer.new(callgraph).print(File.new(filename, 'w'))
36
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_prof_helper
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - cmertz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-02-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ruby-prof
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: just some lines of frequently used ruby prof boilerplate
31
+ email:
32
+ - chris@nimel.de
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/ruby_prof_helper.rb
38
+ homepage: ''
39
+ licenses:
40
+ - MIT
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 1.8.25
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: just some lines of frequently used ruby prof boilerplate
63
+ test_files: []
64
+ has_rdoc: