Module: RequireProf

Defined in:
lib/require_prof.rb,
lib/require_prof/profile.rb,
lib/require_prof/version.rb,
lib/require_prof/require_tree.rb,
lib/require_prof/memory_sampler.rb,
lib/require_prof/printers/tree_printer.rb,
lib/require_prof/printers/table_printer.rb,
lib/require_prof/printers/abstract_printer.rb

Defined Under Namespace

Classes: AbstractPrinter, MemorySampler, Profile, RequireTree, TablePrinter, TreePrinter

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.pauseObject



15
16
17
18
# File 'lib/require_prof.rb', line 15

def self.pause
  ensure_running!
  @profile.pause
end

.paused?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
# File 'lib/require_prof.rb', line 28

def self.paused?
  if defined?(@profile) and @profile
    @profile.paused?
  else
    false
  end
end

.profile(&block) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/require_prof.rb', line 48

def self.profile(&block)
  unless block_given?
    raise(ArgumentError, 'A block must be provided to the profile');
  end

  start
  yield
  stop
end

.require(name) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/require_prof.rb', line 58

def self.require(name)
  if running? && !paused?
    @profile.require(name)
  else
    rp_original_require(name)
  end
end

.resumeObject



36
37
38
39
# File 'lib/require_prof.rb', line 36

def self.resume
  ensure_running!
  @profile.resume
end

.running?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# File 'lib/require_prof.rb', line 20

def self.running?
  if defined?(@profile) and @profile
    @profile.running?
  else
    false
  end
end

.startObject



9
10
11
12
13
# File 'lib/require_prof.rb', line 9

def self.start
  ensure_not_running!
  @profile = Profile.new
  @profile.start
end

.stopObject



41
42
43
44
45
46
# File 'lib/require_prof.rb', line 41

def self.stop
  ensure_running!
  result = @profile.stop
  @profile = nil
  result
end