pry-stackprofiler 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b84a467aa4f568357d73d130ee367ed2ea378059
4
- data.tar.gz: 0134619b03e9eba56602f241a8bd770b0d283819
3
+ metadata.gz: bab723622891110a8020baf2c08735b4cf521e96
4
+ data.tar.gz: d254e2a0774b0569834dedb58d3aa1fcdb797c3a
5
5
  SHA512:
6
- metadata.gz: 8d3ea456c5f5e3fb0db2010ede0cad959c9b622ea419b58df99504a0bd315c12470b011e6e777f718e7b9cd577edda288441cd70b05edab2f2600752a8c4488f
7
- data.tar.gz: bb4dcb7e55ad7c768e15633bb4600bcd0c0db0a90b45bee7a34d919c3c8fee087e12ea7365e77d447d656d00050c40cce5683b9b7cc5621e5a67384d48cbed6d
6
+ metadata.gz: 21794ba5bbd6465895f08bef44831579c9174d4383740dbc77c7eef4aa38a18c0ac2db6c12a64054054e9f9b78bbbddf15b059db665846487de58f4ae8216166
7
+ data.tar.gz: 79090d3cdb1b97bcda5da2b0626fe0bfafa6b807d83947c635bea9609dcdc5f8c14aadb8d44524be23a099cd0fce3ab314173444cbbb9389f33afb1ad9f1758d
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in pry-pry-stackprofiler.gemspec
4
4
  gemspec
5
+ gem 'stackprofx', path: '/Users/aidan/dev/stackprofx'
data/README.md CHANGED
@@ -19,14 +19,14 @@ variable or in `~/.pryrc`.
19
19
 
20
20
  ```ruby
21
21
  # ~/.pryrc
22
- Pry.config.pry_stackprofiler_ui_url = "http://localhost:9292/__stackprofiler/receive"
22
+ Pry.config.pry_stackprofiler_ui_url = "http://localhost:9292/receive"
23
23
  ```
24
24
 
25
25
  or
26
26
 
27
27
  ```bash
28
28
  # ~/.bashrc
29
- export PRY_STACKPROFILER_UI_URL=http://localhost:9292/__stackprofiler/receive
29
+ export PRY_STACKPROFILER_UI_URL=http://localhost:9292/receive
30
30
  ```
31
31
 
32
32
  ## Usage
@@ -44,7 +44,7 @@ In another tab, start up a Pry session:
44
44
  [1] pry(main)* sleep 0.1
45
45
  [1] pry(main)* end
46
46
 
47
- Now navigate to Stackprofiler (probably at [http://localhost:9292/__stackprofiler][3])
47
+ Now navigate to Stackprofiler (probably at [http://localhost:9292/][3])
48
48
  and see which lines were slowest!
49
49
 
50
50
  You can pass an options hash to `Pry::profile` if desired. The most useful key is `interval`
@@ -60,4 +60,4 @@ and specifies how often the code should be sampled in microseconds. The default
60
60
 
61
61
  [1]: https://github.com/glassechidna/stackprofiler
62
62
  [2]: https://github.com/pry/pry
63
- [3]: http://localhost:9292/__stackprofiler
63
+ [3]: http://localhost:9292/
@@ -1,48 +1,48 @@
1
1
  require 'net/http'
2
- require 'stackprof'
3
-
4
- module PryStackprofiler
5
- class << self
6
- @last_profile = nil
7
- @needs_send = false
8
- @blk_obj_id = 0
9
-
10
- def profile opts={}, &blk
11
- # todo: pass through options perhaps?
12
- opts.merge!({mode: :wall, raw: true})
13
- @last_profile = StackProf.run(opts) { blk.call }
14
- @blk_obj_id = RubyVM::InstructionSequence::of(blk).object_id
15
- @needs_send = true
16
- end
17
-
18
- def try_send
19
- return unless @needs_send
20
- @needs_send = false
21
-
22
- pry_file = Pry.line_buffer.join
23
- @last_profile[:files] = {'(pry)' => pry_file}
24
- @last_profile[:suggested_rebase] = @blk_obj_id
25
-
26
- url = URI::parse ui_url
27
- headers = {'Content-Type' => 'application/x-ruby-marshal'}
28
- req = Net::HTTP::Post.new(url.to_s, headers)
29
- req.body = Marshal.dump @last_profile
30
-
31
- response = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
32
- end
33
-
34
- def ui_url
35
- Pry.config.pry_stackprofiler_ui_url ||= ENV['PRY_STACKPROFILER_UI_URL']
36
- end
37
- end
38
- end
2
+ require 'stackprofx'
39
3
 
40
4
  class Pry
41
5
  Pry.config.hooks.add_hook :after_eval, :stackprofiler do |t|
42
- PryStackprofiler::try_send
6
+ Pry::Stackprofiler::try_send
43
7
  end
44
8
 
45
9
  def self.profile opts={}, &blk
46
- PryStackprofiler::profile opts, &blk
10
+ Pry::Stackprofiler::profile opts, &blk
11
+ end
12
+
13
+ module Stackprofiler
14
+ class << self
15
+ @last_profile = nil
16
+ @needs_send = false
17
+ @blk_obj_id = 0
18
+
19
+ def profile opts={}, &blk
20
+ # todo: pass through options perhaps?
21
+ opts.merge!({mode: :wall, raw: true})
22
+ @last_profile = StackProfx.run(opts) { blk.call }
23
+ @blk_obj_id = RubyVM::InstructionSequence::of(blk).object_id
24
+ @needs_send = true
25
+ end
26
+
27
+ def try_send
28
+ return unless @needs_send
29
+ @needs_send = false
30
+
31
+ pry_file = Pry.line_buffer.join
32
+ @last_profile[:files] = {'(pry)' => pry_file}
33
+ @last_profile[:suggested_rebase] = @blk_obj_id
34
+
35
+ url = URI::parse ui_url
36
+ headers = {'Content-Type' => 'application/x-ruby-marshal'}
37
+ req = Net::HTTP::Post.new(url.to_s, headers)
38
+ req.body = Marshal.dump @last_profile
39
+
40
+ response = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
41
+ end
42
+
43
+ def ui_url
44
+ Pry.config.pry_stackprofiler_ui_url ||= ENV['PRY_STACKPROFILER_UI_URL']
45
+ end
46
+ end
47
47
  end
48
48
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'pry-stackprofiler'
5
- spec.version = '0.0.1'
5
+ spec.version = '0.0.2'
6
6
  spec.authors = ['Aidan Steele']
7
7
  spec.email = ['aidan.steele@glassechidna.com.au']
8
8
  spec.summary = %q{A pry plugin to facilitate easy benchmarking of Ruby code.}
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.required_ruby_version = '>= 2.1.0'
18
18
 
19
19
  spec.add_dependency 'pry', '~> 0.10'
20
- spec.add_dependency 'stackprof', '~> 0.2'
20
+ spec.add_dependency 'stackprofx', '~> 0.2'
21
21
 
22
22
  spec.add_development_dependency 'bundler', '~> 1.7'
23
23
  spec.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-stackprofiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aidan Steele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.10'
27
27
  - !ruby/object:Gem::Dependency
28
- name: stackprof
28
+ name: stackprofx
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"