stackviz 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/example/ar_profile.rb +25 -0
- data/lib/stackviz.rb +45 -0
- data/lib/stackviz/version.rb +3 -0
- data/stackviz.gemspec +28 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2fefc37e9be995e7be0e60a742e5b842424eb1ed
|
4
|
+
data.tar.gz: b23545b9db10f62e4483c126f1872a3ed47069e8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b24e1e9a4e80ba101e8043e36f768065fb04661b58b2fcbc3ad017d4a1c2819c89f938e46f191f18ecca1777b10d6840bc976f7de71df5631f23e7e4ea6e2562
|
7
|
+
data.tar.gz: 2a105867962b0e2330a39f60671b2ec372e31e39c0facafb4f62603e875cbb718cec0440093d7c5e33b30c75c3484ddc8d19d3822e750f7ab0263581ce049f5f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Takashi Kokubun
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Stackviz
|
2
|
+
|
3
|
+
Visual stack profiler using [stackprof](https://github.com/tmm1/stackprof).
|
4
|
+
This gem is a thin wrapper of stackprof and provides simple API to see profiling result quickly.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
```bash
|
9
|
+
$ brew install graphviz
|
10
|
+
$ gem install stackviz
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'stackviz'
|
17
|
+
|
18
|
+
Stackviz.profile do
|
19
|
+
1000.times { User.all.to_a }
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
Stackviz converts profiling result to image by `graphviz`, saves it to `/tmp` directory and `open` it.
|
24
|
+
|
25
|
+
![](http://i.gyazo.com/9d57fc063b27aa9748fca559c8499937.png)
|
26
|
+
|
27
|
+
### Specify path to save graph
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Stackviz.profile(path: 'graph.gif') do
|
31
|
+
1000.times { User.all.to_a }
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
### Do not open graph automatically
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
Stackviz.profile(open: false) do
|
39
|
+
1000.times { User.all.to_a }
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
MIT License
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "active_record"
|
2
|
+
require "yaml"
|
3
|
+
require "stackviz"
|
4
|
+
|
5
|
+
ActiveRecord::Base.configurations["profile"] = {
|
6
|
+
adapter: "sqlite3",
|
7
|
+
database: "test.sqlite3",
|
8
|
+
pool: 5,
|
9
|
+
timeout: 5000,
|
10
|
+
}
|
11
|
+
ActiveRecord::Base.establish_connection :profile
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define do
|
14
|
+
create_table :users, force: true do |t|
|
15
|
+
t.column :created_at, :datetime
|
16
|
+
t.column :updated_at, :datetime
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class User < ActiveRecord::Base; end
|
21
|
+
100.times { User.create }
|
22
|
+
|
23
|
+
Stackviz.profile do
|
24
|
+
User.all.to_a
|
25
|
+
end
|
data/lib/stackviz.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "stackviz/version"
|
2
|
+
require "stackprof"
|
3
|
+
|
4
|
+
class Stackviz
|
5
|
+
def self.profile(mode: :cpu, path: nil, open: true, &block)
|
6
|
+
stackviz = self.new(path)
|
7
|
+
stackviz.run(mode, &block)
|
8
|
+
stackviz.open_graph if open
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(path)
|
12
|
+
return @path = path if path
|
13
|
+
|
14
|
+
temp = `mktemp /tmp/stackviz-XXXXXXXX`.strip
|
15
|
+
@path = "#{temp}.gif"
|
16
|
+
`mv #{temp} #{@path}`
|
17
|
+
end
|
18
|
+
|
19
|
+
def run(mode, &block)
|
20
|
+
ensure_dot_existence
|
21
|
+
|
22
|
+
result = StackProf.run(mode: mode, &block)
|
23
|
+
|
24
|
+
Tempfile.open('stackviz') do |f|
|
25
|
+
StackProf::Report.new(result).print_graphviz(nil, f)
|
26
|
+
f.flush
|
27
|
+
|
28
|
+
File.open(@path, 'w') do |graph|
|
29
|
+
`dot -Tgif #{f.path} -o #{graph.path}`
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def open_graph
|
35
|
+
system("open #{@path}")
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def ensure_dot_existence
|
41
|
+
unless system("which dot > /dev/null")
|
42
|
+
abort "`dot` does not exist. Please install graphviz first."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/stackviz.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stackviz/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "stackviz"
|
8
|
+
spec.version = Stackviz::VERSION
|
9
|
+
spec.authors = ["Takashi Kokubun"]
|
10
|
+
spec.email = ["takashikkbn@gmail.com"]
|
11
|
+
spec.summary = %q{Visual stack profiler using stackprof.}
|
12
|
+
spec.description = %q{Visual stack profiler using stackprof. This gem is a thin wrapper of stackprof and provides simple API to see profiling result quickly.}
|
13
|
+
spec.homepage = "https://github.com/k0kubun/stackviz"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "stackprof", "~> 0.2.7"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "activerecord", "~> 4.1"
|
26
|
+
spec.add_development_dependency "sqlite3"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stackviz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takashi Kokubun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: stackprof
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activerecord
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Visual stack profiler using stackprof. This gem is a thin wrapper of
|
98
|
+
stackprof and provides simple API to see profiling result quickly.
|
99
|
+
email:
|
100
|
+
- takashikkbn@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- example/ar_profile.rb
|
111
|
+
- lib/stackviz.rb
|
112
|
+
- lib/stackviz/version.rb
|
113
|
+
- stackviz.gemspec
|
114
|
+
homepage: https://github.com/k0kubun/stackviz
|
115
|
+
licenses:
|
116
|
+
- MIT
|
117
|
+
metadata: {}
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 2.2.2
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: Visual stack profiler using stackprof.
|
138
|
+
test_files: []
|
139
|
+
has_rdoc:
|