gestalt 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -33,20 +33,20 @@ The duration on the outermost call is the total for all nested calls, and the du
33
33
 
34
34
  You can also get a summary after the fact:
35
35
 
36
- Gestalt.profile do
36
+ Gestalt.profile do
37
37
 
38
- slow = Slow.new
39
- slow.method
38
+ slow = Slow.new
39
+ slow.method
40
40
 
41
- end
41
+ end
42
42
 
43
- This will give you oßutput in the following format:
43
+ This will give you output in the following format:
44
44
 
45
45
  +---+--------+----------+
46
46
  | # | action | duration |
47
47
  +---+--------+----------+
48
48
 
49
- The # column indicates how many times each occurredßß, action is the thing that occurred and duration is the total time taken for all occurrences.
49
+ The # column indicates how many times each occurred, action is the thing that occurred and duration is the total time taken for all occurrences.
50
50
 
51
51
  == Copyright
52
52
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/gestalt.gemspec ADDED
@@ -0,0 +1,54 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{gestalt}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["geemus (Wesley Beary)"]
12
+ s.date = %q{2010-04-12}
13
+ s.description = %q{Simple Ruby profiling}
14
+ s.email = %q{wbeary@engineyard.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "gestalt.gemspec",
27
+ "lib/gestalt.rb",
28
+ "lib/gestalt/call.rb",
29
+ "tests/gestalt_tests.rb",
30
+ "tests/tests_helper.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/geemus/gestalt}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.6}
36
+ s.summary = %q{Simple Ruby profiling}
37
+
38
+ if s.respond_to? :specification_version then
39
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
43
+ s.add_runtime_dependency(%q<formatador>, [">= 0.0.12"])
44
+ s.add_development_dependency(%q<shindo>, [">= 0"])
45
+ else
46
+ s.add_dependency(%q<formatador>, [">= 0.0.12"])
47
+ s.add_dependency(%q<shindo>, [">= 0"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<formatador>, [">= 0.0.12"])
51
+ s.add_dependency(%q<shindo>, [">= 0"])
52
+ end
53
+ end
54
+
data/lib/gestalt/call.rb CHANGED
@@ -6,6 +6,7 @@ class Gestalt
6
6
  attr_accessor :action, :finished_at, :location, :started_at
7
7
 
8
8
  def initialize(attributes = {})
9
+ @started_at = Time.now.to_f
9
10
  for key, value in attributes
10
11
  send("#{key}=", value)
11
12
  end
@@ -25,6 +26,13 @@ class Gestalt
25
26
  finished_at - started_at
26
27
  end
27
28
 
29
+ def finish
30
+ @finished_at ||= Time.now.to_f
31
+ for child in children
32
+ child.finish
33
+ end
34
+ end
35
+
28
36
  end
29
37
 
30
38
  end
data/lib/gestalt.rb CHANGED
@@ -42,12 +42,6 @@ class Gestalt
42
42
  end
43
43
 
44
44
  def run(&block)
45
- start
46
- yield
47
- stop
48
- end
49
-
50
- def start
51
45
  Kernel.set_trace_func(
52
46
  lambda do |event, file, line, id, binding, classname|
53
47
  case event
@@ -55,8 +49,7 @@ class Gestalt
55
49
  # p "call #{classname}##{id}"
56
50
  call = Gestalt::Call.new(
57
51
  :action => "#{classname}##{id}",
58
- :location => "#{File.expand_path(file)}:#{line}",
59
- :started_at => Time.now.to_f
52
+ :location => "#{file}:#{line}"
60
53
  )
61
54
  unless @stack.empty?
62
55
  @stack.last.children.push(call)
@@ -66,7 +59,7 @@ class Gestalt
66
59
  # p "return #{classname}##{id}"
67
60
  unless @stack.empty? # we get one of these when we set the trace_func
68
61
  call = @stack.pop
69
- call.finished_at = Time.now.to_f
62
+ call.finish
70
63
  if @stack.empty?
71
64
  @calls << call
72
65
  end
@@ -74,10 +67,18 @@ class Gestalt
74
67
  end
75
68
  end
76
69
  )
77
- end
78
-
79
- def stop
70
+ yield
80
71
  Kernel.set_trace_func(nil)
72
+ @stack.pop # pop Kernel#set_trace_func(nil)
73
+ unless @stack.empty?
74
+ @stack.last.children.pop # pop Kernel#set_trace_func(nil)
75
+ end
76
+ while call = @stack.pop # leftovers, not sure why...
77
+ call.finish
78
+ if @stack.empty?
79
+ @calls << call
80
+ end
81
+ end
81
82
  end
82
83
 
83
84
  def self.profile(&block)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 0
9
- version: 0.0.0
8
+ - 1
9
+ version: 0.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-11 00:00:00 -07:00
17
+ date: 2010-04-12 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -59,6 +59,7 @@ files:
59
59
  - README.rdoc
60
60
  - Rakefile
61
61
  - VERSION
62
+ - gestalt.gemspec
62
63
  - lib/gestalt.rb
63
64
  - lib/gestalt/call.rb
64
65
  - tests/gestalt_tests.rb