stackflame 0.1.0 → 0.2.0

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: 5dbf06da27b2fd52c1399155a2536c092db48afb
4
- data.tar.gz: f7d698f22512e4f3f11330ade273d3d4cea2ed48
3
+ metadata.gz: a371b3ca76216b8729ee4a3486fc141f196207ae
4
+ data.tar.gz: 399a853e4ee66393aa5b52291c7bd0ef84d9d731
5
5
  SHA512:
6
- metadata.gz: 0055086806ac6ff17e2193bb11b564c848c1db96928f2ba859bd2f4e9bab1a979a490af04387ca4c815675ee51a12267f45bd081bcc6e65f47f49e3bdc65fc45
7
- data.tar.gz: f42bf319f4aa44a1dc1681ef0e7af7cdc53cdca20c421450d3ad39fbb1be7cf7df07d2995ec022ab352443189ae47c4df06fb1dc6770e59a3564c9f8988356db
6
+ metadata.gz: a1180e73b1756377ee1c7f945fb1508beb11d3adea98c714afef251ab6d378e47b537da974b8b914d2096344e5bdba08e5abf38be7f9f39979f853ca674e9be4
7
+ data.tar.gz: 1a8076a8822f667b6daa6c19e6d0b9db43f01a2524575701fe91c3521248dba6a7d10bfc863e9f238677e55e53885b48cd88d23adc9d90f33730e5fa34e79819
data/README.md CHANGED
@@ -23,6 +23,12 @@ If you use OSX, flamegraph will be opened with your default browser.
23
23
 
24
24
  ![](http://i.gyazo.com/47871c2de985298c61d0fcca041a34d0.png)
25
25
 
26
+ ### Rack middlware
27
+
28
+ ```ruby
29
+ use Rack::Stackflame, interval: 10
30
+ ```
31
+
26
32
  ## License
27
33
 
28
34
  MIT License
@@ -1,12 +1,13 @@
1
1
  module Rack
2
2
  class Stackflame
3
- def initialize(app)
3
+ def initialize(app, options = {})
4
4
  @app = app
5
+ @options = options
5
6
  end
6
7
 
7
8
  def call(env)
8
9
  result = nil
9
- ::Stackflame.profile do
10
+ ::Stackflame.profile(@options) do
10
11
  result = @app.call(env)
11
12
  end
12
13
  result
@@ -1,3 +1,3 @@
1
1
  class Stackflame
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/stackflame.rb CHANGED
@@ -3,14 +3,21 @@ require "rack/stackflame"
3
3
  require "stackprof"
4
4
 
5
5
  class Stackflame
6
- def self.profile(mode: :cpu, &block)
6
+ DEFAULT_OPTIONS = {
7
+ interval: 1000,
8
+ mode: :cpu,
9
+ raw: true,
10
+ }.freeze
11
+
12
+ def self.profile(options = {}, &block)
7
13
  stackflame = self.new
8
- stackflame.run(mode, &block)
14
+ stackflame.run(options, &block)
9
15
  stackflame.open_flamegraph
10
16
  end
11
17
 
12
- def run(mode, &block)
13
- result = StackProf.run(mode: mode, raw: true, &block)
18
+ def run(options = {}, &block)
19
+ options = DEFAULT_OPTIONS.merge(options)
20
+ result = StackProf.run(options, &block)
14
21
 
15
22
  File.open(temp_js_path, 'w') do |f|
16
23
  StackProf::Report.new(result).print_flamegraph(f)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackflame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2015-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stackprof
@@ -138,4 +138,3 @@ signing_key:
138
138
  specification_version: 4
139
139
  summary: Stackflame provides a simple API to deal with Flamegraph of stackprof.
140
140
  test_files: []
141
- has_rdoc: