stackprof-webnav 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 +4 -4
- data/README.md +6 -0
- data/bin/stackprof-webnav +9 -4
- data/lib/stackprof-webnav/presenter.rb +1 -1
- data/lib/stackprof-webnav/server.rb +15 -9
- data/lib/stackprof-webnav/version.rb +2 -2
- data/stackprof-webnav.gemspec +2 -2
- metadata +10 -11
- data/lib/stackprof-webnav/stackprof_presenter.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0b0477364b7de56855e675ddd67faf38ee67c30
|
4
|
+
data.tar.gz: 351fabc3894db01a0e7bf7aad98a946698500f1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21b62f009b154a395474d1c56d736f1fe886b72550188c47623bcf558a1c610b62776d6f002cfde25b6d746290b0c528f819da6be459d46020aebac4d9b77e28
|
7
|
+
data.tar.gz: 9cb2e6053bf5827c487815004b50f48189a29f2bb069774fb3db1b17339b0e975a73587dae29db97c0e7a82f16b0c98e7b50172af6963278fe6aa503468c2c48
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# StackProf Web navigator
|
2
2
|
|
3
|
+
__WARNING__: early version, no tests, may have bugs.
|
4
|
+
|
3
5
|
Provides a web ui to inspect stackprof dumps.
|
4
6
|
|
7
|
+
## Screenshots
|
8
|
+
|
5
9
|
![main screenshot][main-screenshot]
|
6
10
|
|
7
11
|
![method screenshot][method-screenshot]
|
@@ -18,7 +22,9 @@ $ gem install stackprof-webnav
|
|
18
22
|
### Pass a dump to it
|
19
23
|
```bash
|
20
24
|
$ stackprof-webnav /path/to/stackprof.dump
|
25
|
+
$ stackprof-webnav http://path/to/stackprof.dump
|
21
26
|
```
|
27
|
+
If the argument passed does not exist locally, it is assumed to be a URI and is treated as such.
|
22
28
|
|
23
29
|
See [stackprof gem][create-dump] homepage to learn how to create dumps.
|
24
30
|
|
data/bin/stackprof-webnav
CHANGED
@@ -7,7 +7,7 @@ options = {
|
|
7
7
|
}
|
8
8
|
|
9
9
|
parser = OptionParser.new(ARGV) do |o|
|
10
|
-
o.banner = "Usage: stackprof-webnav file.dump [-p NUMBER]"
|
10
|
+
o.banner = "Usage: stackprof-webnav file.dump|http://path/to/file.dump [-p NUMBER]"
|
11
11
|
o.on('-p [PORT]', 'Server port') {|port| options[:port] = port }
|
12
12
|
end
|
13
13
|
|
@@ -15,7 +15,12 @@ parser.parse!
|
|
15
15
|
parser.abort(parser.help) if ARGV.empty?
|
16
16
|
|
17
17
|
file = ARGV.pop
|
18
|
-
|
19
18
|
server = StackProf::Webnav::Server
|
20
|
-
|
21
|
-
|
19
|
+
|
20
|
+
if File.exists?(file)
|
21
|
+
server.report_dump_path = File.expand_path(file)
|
22
|
+
else
|
23
|
+
server.report_dump_url = file
|
24
|
+
end
|
25
|
+
|
26
|
+
server.run! options[:port]
|
@@ -1,17 +1,28 @@
|
|
1
1
|
require 'nyny'
|
2
2
|
require 'haml'
|
3
3
|
require "stackprof"
|
4
|
-
require 'sprockets'
|
4
|
+
require 'sprockets/nyny'
|
5
|
+
require 'net/http'
|
5
6
|
require_relative 'presenter'
|
6
7
|
|
7
8
|
module StackProf
|
8
9
|
module Webnav
|
9
10
|
class Server < NYNY::App
|
11
|
+
register Sprockets::NYNY
|
12
|
+
config.assets.paths << File.join(__dir__, 'css')
|
13
|
+
|
10
14
|
class << self
|
11
|
-
attr_accessor :report_dump_path
|
15
|
+
attr_accessor :report_dump_path, :report_dump_url
|
12
16
|
|
13
17
|
def presenter
|
14
|
-
|
18
|
+
return @presenter unless @presenter.nil?
|
19
|
+
content = if report_dump_path.nil?
|
20
|
+
Net::HTTP.get(URI.parse(report_dump_url))
|
21
|
+
else
|
22
|
+
File.open(report_dump_path).read
|
23
|
+
end
|
24
|
+
|
25
|
+
report = StackProf::Report.new(Marshal.load(content))
|
15
26
|
@presenter ||= Presenter.new(report)
|
16
27
|
end
|
17
28
|
end
|
@@ -39,13 +50,8 @@ module StackProf
|
|
39
50
|
end
|
40
51
|
end
|
41
52
|
|
42
|
-
sprockets = Sprockets::Environment.new do |env|
|
43
|
-
env.append_path(File.join(__dir__, 'css'))
|
44
|
-
end.index
|
45
|
-
builder.map('/assets'){ run sprockets }
|
46
|
-
|
47
53
|
get '/' do
|
48
|
-
@file = Server.report_dump_path
|
54
|
+
@file = Server.report_dump_path || Server.report_dump_url
|
49
55
|
@action = "overview"
|
50
56
|
@frames = presenter.overview_frames
|
51
57
|
render_with_layout :overview
|
data/stackprof-webnav.gemspec
CHANGED
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.bindir = 'bin'
|
22
22
|
spec.executables << 'stackprof-webnav'
|
23
23
|
|
24
|
-
spec.add_dependency "nyny", "~> 3.
|
24
|
+
spec.add_dependency "nyny", "~> 3.4"
|
25
25
|
spec.add_dependency "haml", "~> 4.0"
|
26
26
|
spec.add_dependency "stackprof", "~> 0.2"
|
27
|
-
spec.add_dependency "sprockets", "
|
27
|
+
spec.add_dependency "sprockets-nyny", "0.0.3"
|
28
28
|
spec.add_development_dependency "bundler", "~> 1.5"
|
29
29
|
spec.add_development_dependency "rake", "~> 10.1"
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackprof-webnav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Lisnic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nyny
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: haml
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: sprockets
|
56
|
+
name: sprockets-nyny
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.0.3
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.0.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,7 +115,6 @@ files:
|
|
115
115
|
- lib/stackprof-webnav/css/normalize.css
|
116
116
|
- lib/stackprof-webnav/presenter.rb
|
117
117
|
- lib/stackprof-webnav/server.rb
|
118
|
-
- lib/stackprof-webnav/stackprof_presenter.rb
|
119
118
|
- lib/stackprof-webnav/version.rb
|
120
119
|
- lib/stackprof-webnav/views/file.haml
|
121
120
|
- lib/stackprof-webnav/views/layout.haml
|
@@ -145,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
144
|
version: '0'
|
146
145
|
requirements: []
|
147
146
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.2.
|
147
|
+
rubygems_version: 2.2.2
|
149
148
|
signing_key:
|
150
149
|
specification_version: 4
|
151
150
|
summary: View stackprof dumps in a web UI
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'better_errors'
|
2
|
-
|
3
|
-
module StackProf
|
4
|
-
module Webnav
|
5
|
-
class Presenter
|
6
|
-
attr_reader :report
|
7
|
-
def initialize report
|
8
|
-
@report = report
|
9
|
-
end
|
10
|
-
|
11
|
-
def overview_frames
|
12
|
-
report.frames.map do |frame, info|
|
13
|
-
call, total = info.values_at(:samples, :total_samples)
|
14
|
-
{
|
15
|
-
:total => total,
|
16
|
-
:total_pct => percent(total.to_f/report.overall_samples),
|
17
|
-
:samples => call,
|
18
|
-
:samples_pct => percent(call.to_f/report.overall_samples),
|
19
|
-
:method => info[:name]
|
20
|
-
}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def method_info name
|
25
|
-
name = /#{Regexp.escape name}/ unless Regexp === name
|
26
|
-
frames = report.frames.select do |frame, info|
|
27
|
-
info[:name] =~ name
|
28
|
-
end.map do |frame, info|
|
29
|
-
file, line = info.values_at(:file, :line)
|
30
|
-
|
31
|
-
{
|
32
|
-
:callers => callers(frame, info),
|
33
|
-
:callees => callees(frame, info),
|
34
|
-
:location => "#{file}:#{line}",
|
35
|
-
:source => BetterErrors::CodeFormatter::HTML.new(file, line).output
|
36
|
-
}
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def percent value
|
43
|
-
"%2.2f%" % (value*100)
|
44
|
-
end
|
45
|
-
|
46
|
-
def callers frame, info
|
47
|
-
report.data[:frames].select do |id, other|
|
48
|
-
other[:edges] && other[:edges].include?(frame)
|
49
|
-
end.map do |id, other|
|
50
|
-
[other[:name], other[:edges][frame]]
|
51
|
-
end.sort_by(&:last).reverse.map do |name, weight|
|
52
|
-
{
|
53
|
-
:weight => weight,
|
54
|
-
:pct => percent(weight.to_f/info[:total_samples]),
|
55
|
-
:method => name
|
56
|
-
}
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def callees frame, info
|
61
|
-
(info[:edges] || []).map do |k, weight|
|
62
|
-
[report.data[:frames][k][:name], weight]
|
63
|
-
end.sort_by { |k,v| -v }.map do |name, weight|
|
64
|
-
{
|
65
|
-
:weight => weight,
|
66
|
-
:pct => percent(weight.to_f/(info[:total_samples]-info[:samples])),
|
67
|
-
:method => name
|
68
|
-
}
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|