stack_tracy 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,11 @@
1
1
  = StackTracy CHANGELOG
2
2
 
3
+ == Version 0.1.3 (August 19, 2012)
4
+
5
+ * Being able to compile StackTracy native extension on Windows (thanks ramsees for issuing)
6
+ * Tackled C compile warnings
7
+ * Not using Launchy for opening the generated HTML page when running on Windows
8
+
3
9
  == Version 0.1.2 (August 16, 2012)
4
10
 
5
11
  * Tackling non-calculated durations within ui/index.html.erb
data/README.md CHANGED
@@ -10,6 +10,8 @@ The gem is partly written in C to reduce the application performance as minimal
10
10
 
11
11
  ![Dick .. Stack Tracy](http://codehero.es/images/stack_tracy.jpg)
12
12
 
13
+ Watch ["**Using StackTracy within a small Sinatra application**"](https://vimeo.com/archan937/stacktracy) to see StackTracy in action!
14
+
13
15
  ## Installation
14
16
 
15
17
  ### Add `StackTracy` to your Gemfile
@@ -140,12 +142,13 @@ You can dump (optionally filtered) recorded stack events to a CSV file.
140
142
  [2] pry(main)> puts "testing"
141
143
  => testing
142
144
  [3] pry(main)> StackTracy.stop
145
+ [4] pry(main)> StackTracy.print
143
146
  Kernel#puts <0.000121>
144
147
  IO#puts <0.000091>
145
148
  IO#write <0.000032>
146
149
  IO#write <0.000020>
147
150
  => nil
148
- [4] pry(main)> StackTracy.dump "result.csv"
151
+ [5] pry(main)> StackTracy.dump "result.csv"
149
152
  => true
150
153
 
151
154
  #### CSV sample file
@@ -287,7 +290,7 @@ Open the Sinatra application in your browser at [http://localhost:4567](http://l
287
290
 
288
291
  ### Taking more control
289
292
 
290
- I can imagine that you don't want to hook into every Sinatra request. So you can pass a block which will be yielded before every request. The request will traced when it does **note** return either `false` or `nil`:
293
+ I can imagine that you don't want to hook into every Sinatra request. So you can pass a block which will be yielded before every request. The request will traced when it does **not** return either `false` or `nil`:
291
294
 
292
295
  use StackTracy::Sinatra do |path, params|
293
296
  path == "/" #=> only trace "http://localhost:4567"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -58,7 +58,7 @@ for n in [5, 100] do
58
58
  end
59
59
 
60
60
  # $ ruby stack_tracy/benchmarks/benchmark.rb
61
- # 0.05799508094787598
62
- # 2.315906047821045
63
- # 2.786252021789551
64
- # 5.190935850143433
61
+ # 0.035907
62
+ # 2.096276
63
+ # 2.575487
64
+ # 4.770742
@@ -134,7 +134,6 @@ static void stack_tracy_trap(rb_event_flag_t event, NODE *node, VALUE self, ID i
134
134
  }
135
135
 
136
136
  VALUE stack_tracy_start(VALUE self, VALUE only_names, VALUE exclude_names) {
137
- int i;
138
137
  char *token;
139
138
 
140
139
  token = strtok((char *) RSTRING_PTR(only_names), " ");
@@ -144,10 +143,8 @@ VALUE stack_tracy_start(VALUE self, VALUE only_names, VALUE exclude_names) {
144
143
  only_size++;
145
144
  only = (RubyClass *) realloc (only, only_size * sizeof(RubyClass));
146
145
 
147
- RubyClass klass;
148
- klass.name = (char *) token;
149
- klass.klass = (VALUE *) rb_path2class((char *) token);
150
- only[only_size - 1] = klass;
146
+ only[only_size - 1].name = (char *) token;
147
+ only[only_size - 1].klass = (VALUE *) rb_path2class((char *) token);
151
148
 
152
149
  token = strtok(NULL, " ");
153
150
  }
@@ -159,10 +156,8 @@ VALUE stack_tracy_start(VALUE self, VALUE only_names, VALUE exclude_names) {
159
156
  exclude_size++;
160
157
  exclude = (RubyClass *) realloc (exclude, exclude_size * sizeof(RubyClass));
161
158
 
162
- RubyClass klass;
163
- klass.name = (char *) token;
164
- klass.klass = (VALUE *) rb_path2class((char *) token);
165
- exclude[exclude_size - 1] = klass;
159
+ exclude[exclude_size - 1].name = (char *) token;
160
+ exclude[exclude_size - 1].klass = (VALUE *) rb_path2class((char *) token);
166
161
 
167
162
  token = strtok(NULL, " ");
168
163
  }
@@ -180,7 +175,6 @@ VALUE stack_tracy_start(VALUE self, VALUE only_names, VALUE exclude_names) {
180
175
 
181
176
  VALUE stack_tracy_stop(VALUE self) {
182
177
  VALUE events, event;
183
- ID id;
184
178
  const char *method;
185
179
  int i;
186
180
 
@@ -4,7 +4,6 @@
4
4
  #include <ruby.h>
5
5
  #include <stdbool.h>
6
6
  #include <time.h>
7
- #include <sys/time.h>
8
7
  #include <string.h>
9
8
 
10
9
  typedef struct event_info_t {
data/lib/stack_tracy.rb CHANGED
@@ -106,7 +106,11 @@ module StackTracy
106
106
  end
107
107
 
108
108
  if File.exists?(index)
109
- Launchy.open("file://#{index}")
109
+ if RbConfig::CONFIG["host_os"].match(/(mswin|mingw)/) # I know, don't say it!
110
+ `start file://#{index}`
111
+ else
112
+ Launchy.open("file://#{index}")
113
+ end
110
114
  nil
111
115
  else
112
116
  raise Error, "Could not locate StackTracy file"
@@ -149,6 +153,7 @@ private
149
153
  end
150
154
 
151
155
  def process?(event_info, only)
156
+ return false if "#{event_info.object}" == "StackTracy"
152
157
  return true if only.empty?
153
158
  only.any?{|x| event_info.matches?(x)}
154
159
  end
@@ -1,7 +1,7 @@
1
1
  module StackTracy #:nodoc:
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 2
4
+ TINY = 3
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
data/stack_tracy.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
14
  gem.name = "stack_tracy"
15
15
  gem.require_paths = ["lib"]
16
- gem.version = "0.1.2"
16
+ gem.version = "0.1.3"
17
17
 
18
18
  gem.add_dependency "rich_support", "~> 0.1.2"
19
19
  gem.add_dependency "launchy", "2.1.0"
@@ -57,16 +57,19 @@ module Unit
57
57
  puts "testing"
58
58
  end
59
59
  file, line = __FILE__, __LINE__ - 2
60
+ st = File.expand_path("../../../lib/stack_tracy.rb", __FILE__)
60
61
 
61
62
  assert_equal [
62
- {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => Kernel, :method => "puts" , :call => "Kernel#puts"},
63
- {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "puts" , :call => "IO#puts" },
64
- {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" },
65
- {:event => "c-return", :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" },
66
- {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" },
67
- {:event => "c-return", :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" },
68
- {:event => "c-return", :file => file, :line => line, :singleton => false, :object => IO , :method => "puts" , :call => "IO#puts" },
69
- {:event => "c-return", :file => file, :line => line, :singleton => false, :object => Kernel, :method => "puts" , :call => "Kernel#puts"}
63
+ {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => Kernel , :method => "puts" , :call => "Kernel#puts" },
64
+ {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "puts" , :call => "IO#puts" },
65
+ {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" },
66
+ {:event => "c-return", :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" },
67
+ {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" },
68
+ {:event => "c-return", :file => file, :line => line, :singleton => false, :object => IO , :method => "write", :call => "IO#write" },
69
+ {:event => "c-return", :file => file, :line => line, :singleton => false, :object => IO , :method => "puts" , :call => "IO#puts" },
70
+ {:event => "c-return", :file => file, :line => line, :singleton => false, :object => Kernel , :method => "puts" , :call => "Kernel#puts" },
71
+ {:event => "call" , :file => st , :line => 35 , :singleton => false, :object => StackTracy, :method => "stop" , :call => "StackTracy#stop" },
72
+ {:event => "c-call" , :file => st , :line => 36 , :singleton => 0 , :object => StackTracy, :method => "_stop", :call => "StackTracy._stop"}
70
73
  ], StackTracy.stack_trace.collect{ |event_info|
71
74
  event_info.to_hash.tap do |hash|
72
75
  assert hash.delete(:nsec)
@@ -75,10 +78,7 @@ module Unit
75
78
  }
76
79
 
77
80
  assert StackTracy.stack_trace.first.call?
78
- assert !StackTracy.stack_trace.last.call?
79
-
80
81
  assert !StackTracy.stack_trace.first.return?
81
- assert StackTracy.stack_trace.last.return?
82
82
 
83
83
  StackTracy.config do |c|
84
84
  c.exclude = ["IO"]
@@ -89,8 +89,10 @@ module Unit
89
89
  file, line = __FILE__, __LINE__ - 2
90
90
 
91
91
  assert_equal [
92
- {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => Kernel, :method => "puts" , :call => "Kernel#puts"},
93
- {:event => "c-return", :file => file, :line => line, :singleton => false, :object => Kernel, :method => "puts" , :call => "Kernel#puts"}
92
+ {:event => "c-call" , :file => file, :line => line, :singleton => false, :object => Kernel , :method => "puts" , :call => "Kernel#puts" },
93
+ {:event => "c-return", :file => file, :line => line, :singleton => false, :object => Kernel , :method => "puts" , :call => "Kernel#puts" },
94
+ {:event => "call" , :file => st , :line => 35 , :singleton => false, :object => StackTracy, :method => "stop" , :call => "StackTracy#stop" },
95
+ {:event => "c-call" , :file => st , :line => 36 , :singleton => 0 , :object => StackTracy, :method => "_stop", :call => "StackTracy._stop"}
94
96
  ], StackTracy.stack_trace.collect{ |event_info|
95
97
  event_info.to_hash.tap do |hash|
96
98
  assert hash.delete(:nsec)
@@ -105,7 +107,7 @@ module Unit
105
107
  puts "testing"
106
108
  end
107
109
 
108
- assert_equal true, StackTracy.stack_trace.empty?
110
+ assert_equal 2, StackTracy.stack_trace.size
109
111
  end
110
112
 
111
113
  it "should return a printable version of the stack trace" do
@@ -16,7 +16,7 @@ StackTracy = (function() {
16
16
  });
17
17
 
18
18
  return {
19
- version: "0.1.2",
19
+ version: "0.1.3",
20
20
  sort: function(column) {
21
21
  sortation[column] = sortation[column] == "asc" ? "desc" : "asc";
22
22
  $("#cumulatives>.body>div").tsort("span:eq(" + column + ")[abbr]", {
metadata CHANGED
@@ -1,58 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: stack_tracy
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.2
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.1.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Paul Engel
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-16 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2012-08-18 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
15
16
  name: rich_support
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 0.1.2
22
- type: :runtime
23
17
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
18
+ requirement: &id001 !ruby/object:Gem::Requirement
25
19
  none: false
26
- requirements:
20
+ requirements:
27
21
  - - ~>
28
- - !ruby/object:Gem::Version
22
+ - !ruby/object:Gem::Version
29
23
  version: 0.1.2
30
- - !ruby/object:Gem::Dependency
31
- name: launchy
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - '='
36
- - !ruby/object:Gem::Version
37
- version: 2.1.0
38
24
  type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: launchy
39
28
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: &id002 !ruby/object:Gem::Requirement
41
30
  none: false
42
- requirements:
43
- - - '='
44
- - !ruby/object:Gem::Version
31
+ requirements:
32
+ - - "="
33
+ - !ruby/object:Gem::Version
45
34
  version: 2.1.0
46
- description: Investigate and detect slow methods within the stack trace of your Ruby
47
- (optionally Sinatra) application
48
- email:
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ description: Investigate and detect slow methods within the stack trace of your Ruby (optionally Sinatra) application
38
+ email:
49
39
  - paul.engel@holder.nl
50
- executables:
40
+ executables:
51
41
  - tracy
52
- extensions:
42
+ extensions:
53
43
  - ext/stack_tracy/extconf.rb
54
44
  extra_rdoc_files: []
55
- files:
45
+
46
+ files:
56
47
  - .gitignore
57
48
  - CHANGELOG.rdoc
58
49
  - Gemfile
@@ -85,30 +76,33 @@ files:
85
76
  - ui/index.html.erb
86
77
  homepage: https://github.com/archan937/stack_tracy
87
78
  licenses: []
79
+
88
80
  post_install_message:
89
81
  rdoc_options: []
90
- require_paths:
82
+
83
+ require_paths:
91
84
  - lib
92
- required_ruby_version: !ruby/object:Gem::Requirement
85
+ required_ruby_version: !ruby/object:Gem::Requirement
93
86
  none: false
94
- requirements:
95
- - - ! '>='
96
- - !ruby/object:Gem::Version
97
- version: '0'
98
- required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
92
  none: false
100
- requirements:
101
- - - ! '>='
102
- - !ruby/object:Gem::Version
103
- version: '0'
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
104
97
  requirements: []
98
+
105
99
  rubyforge_project:
106
- rubygems_version: 1.8.24
100
+ rubygems_version: 1.8.17
107
101
  signing_key:
108
102
  specification_version: 3
109
- summary: Investigate and detect slow methods within the stack trace of your Ruby (optionally
110
- Sinatra) application
111
- test_files:
103
+ summary: Investigate and detect slow methods within the stack trace of your Ruby (optionally Sinatra) application
104
+ test_files:
112
105
  - test/test_helper.rb
113
106
  - test/unit/test_kernel.rb
114
107
  - test/unit/test_tracy.rb
108
+ has_rdoc: