rackprof 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ <% content_for :javascript do %>
2
+ <script src='/rackprof/index.js'></script>
3
+ <% end %>
4
+
5
+ <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
6
+ <div class="row">
7
+ <div class="col-xs-6 col-sm-6">
8
+ <h4>GC count</h4>
9
+ <canvas id='gc_chart' width='500' height='280'></canvas>
10
+ <ul id='gc_legend'></ul>
11
+ </div>
12
+ <div class="col-xs-6 col-sm-6">
13
+ <h4>Total object count</h4>
14
+ <canvas id='total_object' width='500' height='280'></canvas>
15
+ <ul id='total_object_legend'></ul>
16
+ </div>
17
+ </div>
18
+ <div class="row">
19
+ <div class="col-xs-6 col-sm-6">
20
+ <h4>malloc increase count</h4>
21
+ <canvas id='malloc_increase' width='500' height='280'></canvas>
22
+ <ul id='malloc_increase_legend'></ul>
23
+ </div>
24
+ <div class="col-xs-6 col-sm-6">
25
+ <h4>old object count</h4>
26
+ <canvas id='old_objects' width='500' height='280'></canvas>
27
+ <ul id='old_objects_legend'></ul>
28
+ </div>
29
+ </div>
30
+ </div>
@@ -0,0 +1,51 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>rack profiler</title>
5
+ <meta charset="utf-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
9
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
10
+ <link rel="stylesheet" href="/rackprof/dashboard.css">
11
+ <link rel="stylesheet" href="/rackprof/main.css" type="text/css" media="all">
12
+ <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
13
+ <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
14
+ <!--[if lt IE 9]>
15
+ <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
16
+ <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
17
+ <![endif]-->
18
+ </head>
19
+ <body>
20
+ <nav class="navbar navbar-inverse navbar-fixed-top">
21
+ <div class="container-fluid">
22
+ <div class="navbar-header">
23
+ <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
24
+ <span class="sr-only">Toggle navigation</span>
25
+ <span class="icon-bar"></span>
26
+ <span class="icon-bar"></span>
27
+ <span class="icon-bar"></span>
28
+ </button>
29
+ <a class="navbar-brand" href="/rackprof">rack profiler</a>
30
+ </div>
31
+ </div>
32
+ </nav>
33
+
34
+ <div class="container-fluid">
35
+ <div class="row">
36
+ <div class="col-sm-3 col-md-2 sidebar">
37
+ <ul class="nav nav-sidebar">
38
+ <li class="<%= active_class('/') %>"><a href="/rackprof">GC Profile<span class="sr-only">(current)</span></a></li>
39
+ <li class="<%= active_class('/request') %>"><a href="/rackprof/request">Request Profile</a></li>
40
+ </ul>
41
+ </div>
42
+ <%= yield %>
43
+ </div>
44
+ </div>
45
+
46
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
47
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
48
+ <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js'></script>
49
+ <%= yield_content :javascript %>
50
+ </body>
51
+ </html>
@@ -0,0 +1,15 @@
1
+ <% content_for :javascript do %>
2
+ <script src='/rackprof/request.js'></script>
3
+ <script src='/rackprof/viz.js'></script>
4
+ <% end %>
5
+
6
+ <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
7
+ <div class="row">
8
+ <div class="col-xs-12 col-sm-12">
9
+ <h4>Request</h4>
10
+
11
+ <pre id='profile'></pre>
12
+ <script type="text/vnd.graphviz" id="profile"></script>
13
+ </div>
14
+ </div>
15
+ </div>
@@ -0,0 +1,3 @@
1
+ module Rackprof
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,43 @@
1
+ require 'sinatra/base'
2
+ require 'sinatra/content_for'
3
+
4
+ module Rackprof
5
+ class Web < Sinatra::Base
6
+ helpers Sinatra::ContentFor
7
+
8
+ set :root, File.expand_path(File.dirname(__FILE__) + '/templates')
9
+ set :public_folder, proc { "#{root}/assets" }
10
+ set :views, proc { "#{root}/views" }
11
+
12
+ helpers do
13
+ def active_class(path)
14
+ 'active' if @env['PATH_INFO'] == path
15
+ end
16
+ end
17
+
18
+ get '/' do
19
+ GCNotify.instance.start
20
+ erb :index
21
+ end
22
+
23
+ get '/gc_stream', provides: 'text/event-stream' do
24
+ stream :keep_open do |out|
25
+ observer = GCObserver.new(out)
26
+ GCNotify.instance.add_observer(observer)
27
+ out.callback { GCNotify.instance.delete_observer(observer) }
28
+ end
29
+ end
30
+
31
+ get '/request' do
32
+ erb :request
33
+ end
34
+
35
+ get '/request_stream', provides: 'text/event-stream' do
36
+ stream :keep_open do |out|
37
+ observer = RequestObserver.new(out)
38
+ RequestNotify.instance.add_observer(observer)
39
+ out.callback { RequestNotify.instance.delete_observer(observer) }
40
+ end
41
+ end
42
+ end
43
+ end
data/rackprof.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rackprof/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rackprof"
8
+ spec.version = Rackprof::VERSION
9
+ spec.authors = ["Norimasa Ando"]
10
+ spec.email = ["norimasa.ando@gmail.com"]
11
+
12
+ spec.summary = %q{Profile ruby code for Rails and other Rack apps.}
13
+ spec.description = %q{Provides a profiler page of the ruby execution which has infomation of gc and object allocation.}
14
+ spec.homepage = "https://github.com/hbd225/rackprof"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'sinatra'
21
+ spec.add_dependency 'sinatra-contrib'
22
+ spec.add_dependency 'eventmachine'
23
+ spec.add_dependency 'stackprof'
24
+ spec.add_development_dependency 'bundler', '~> 1.9'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rackprof
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Norimasa Ando
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra-contrib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: eventmachine
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: stackprof
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ description: Provides a profiler page of the ruby execution which has infomation of
98
+ gc and object allocation.
99
+ email:
100
+ - norimasa.ando@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/rackprof.rb
114
+ - lib/rackprof/engine.rb
115
+ - lib/rackprof/gc_notify.rb
116
+ - lib/rackprof/gc_observer.rb
117
+ - lib/rackprof/middleware.rb
118
+ - lib/rackprof/observer.rb
119
+ - lib/rackprof/rails.rb
120
+ - lib/rackprof/request_notify.rb
121
+ - lib/rackprof/request_observer.rb
122
+ - lib/rackprof/templates/assets/dashboard.css
123
+ - lib/rackprof/templates/assets/index.js
124
+ - lib/rackprof/templates/assets/main.css
125
+ - lib/rackprof/templates/assets/request.js
126
+ - lib/rackprof/templates/assets/viz.js
127
+ - lib/rackprof/templates/views/index.erb
128
+ - lib/rackprof/templates/views/layout.erb
129
+ - lib/rackprof/templates/views/request.erb
130
+ - lib/rackprof/version.rb
131
+ - lib/rackprof/web.rb
132
+ - rackprof.gemspec
133
+ homepage: https://github.com/hbd225/rackprof
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.4.5
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Profile ruby code for Rails and other Rack apps.
157
+ test_files: []