Class: RSpecProf
- Inherits:
-
Object
show all
- Extended by:
- FilenameHelpers
- Defined in:
- lib/rspec-prof.rb,
lib/rspec-prof/filename_helpers.rb
Defined Under Namespace
Modules: FilenameHelpers
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
file_extension, filename_for, output_dir, path_for
Class Attribute Details
.printer_class ⇒ Object
Returns the value of attribute printer_class.
12
13
14
|
# File 'lib/rspec-prof.rb', line 12
def printer_class
@printer_class
end
|
Class Method Details
.profile(filename) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/rspec-prof.rb', line 14
def profile filename
profiler = new.start
yield
ensure
profiler.save_to filename
end
|
Instance Method Details
#profiling? ⇒ Boolean
35
36
37
|
# File 'lib/rspec-prof.rb', line 35
def profiling?
@profiling
end
|
#result ⇒ Object
39
40
41
|
# File 'lib/rspec-prof.rb', line 39
def result
@result
end
|
#save_to(filename) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/rspec-prof.rb', line 43
def save_to filename
stop
FileUtils.mkdir_p File.dirname(filename)
File.open(filename, "w") do |f|
printer = RSpecProf.printer_class.new(result)
printer.print(f, :min_percent => 1)
end
end
|
#start ⇒ Object
22
23
24
25
26
27
|
# File 'lib/rspec-prof.rb', line 22
def start
return if @profiling
@profiling = true
RubyProf.start
self
end
|
#stop ⇒ Object
29
30
31
32
33
|
# File 'lib/rspec-prof.rb', line 29
def stop
return unless @profiling
@profiling = false
@result = RubyProf.stop
end
|