jruby-profiler-flame_graph_profile_printer 0.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +57 -0
- data/Rakefile +3 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/powers.rb +19 -0
- data/example1.png +0 -0
- data/example2.png +0 -0
- data/jruby-profiler-flame_graph_profile_printer.gemspec +26 -0
- data/lib/jruby/profiler/flame_graph_profile_printer.rb +58 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 109f07751c4174383f4e8c83417ebde710b4528a
|
4
|
+
data.tar.gz: ea7f3819e669ca9199b666fe5987c31860bd14e4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a8504643413e325a5944f28f1b1b00b10445a5a9ef3ce76d4f0222f07835b9fbe5090497a49f65eb1dd764650b09e8eb41b8c2de7f56054833582664f7b9131e
|
7
|
+
data.tar.gz: 3d7661aea80b897a14ef0bf8222e18a5767eee86bec1ca6611c5e9221ea7073089099538da5df19ada2c47e3e35f1e21652e92db64336be2abc4a23b27b8d5d1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at film42@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 film42
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# JRuby::Profiler::FlameGraphProfilePrinter
|
2
|
+
|
3
|
+
This is a JRuby Profiler Printer that will dump a profile into a form for usage with FlameGraph.
|
4
|
+
It only builds a FlameGraph from the thread that wraps the profiler, because I'm not sure the JRuby
|
5
|
+
profiler supports multiple threads right now.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install jruby-profiler-flame_graph_profile_printer
|
10
|
+
|
11
|
+
## Example
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require "jruby/profiler/flame_graph_profile_printer"
|
15
|
+
|
16
|
+
def ok
|
17
|
+
3 ** 3
|
18
|
+
end
|
19
|
+
|
20
|
+
def test
|
21
|
+
ok ** 3
|
22
|
+
end
|
23
|
+
|
24
|
+
result = JRuby::Profiler.profile do
|
25
|
+
# Do some expensive stuff.
|
26
|
+
10_000.times do
|
27
|
+
test ** 3
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
printer = JRuby::Profiler::FlameGraphProfilePrinter.new(result)
|
32
|
+
printer.printProfile(STDOUT)
|
33
|
+
```
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
```
|
38
|
+
# Assuming you have the above example saved as "powers.rb".
|
39
|
+
jruby --profile.api powers.rb | ./FlameGraph/flamegraph.pl > output.svg
|
40
|
+
```
|
41
|
+
|
42
|
+
Where `./FlameGraph/flamegraph.pl` is a cloned version of [FlameGraph](https://github.com/brendangregg/FlameGraph).
|
43
|
+
|
44
|
+
![screenshot](./example1.png)
|
45
|
+
|
46
|
+
**Here's a slightly more complex example:**
|
47
|
+
|
48
|
+
![screenshot](./example2.png)
|
49
|
+
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/film42/jruby-profiler-flame_graph_profile_printer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "jruby/profiler/flame_graph_profile_printer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/example/powers.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "jruby/profiler/flame_graph_profile_printer"
|
2
|
+
|
3
|
+
def ok
|
4
|
+
3 ** 3
|
5
|
+
end
|
6
|
+
|
7
|
+
def test
|
8
|
+
ok ** 3
|
9
|
+
end
|
10
|
+
|
11
|
+
result = JRuby::Profiler.profile do
|
12
|
+
# Do some expensive stuff.
|
13
|
+
10_000.times do
|
14
|
+
test ** 3
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
printer = JRuby::Profiler::FlameGraphProfilePrinter.new(result)
|
19
|
+
printer.printProfile(STDOUT)
|
data/example1.png
ADDED
Binary file
|
data/example2.png
ADDED
Binary file
|
@@ -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 'jruby/profiler/flame_graph_profile_printer'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jruby-profiler-flame_graph_profile_printer"
|
8
|
+
spec.version = JRuby::Profiler::FlameGraphProfilePrinter::VERSION
|
9
|
+
spec.authors = ["Garrett Thornburg"]
|
10
|
+
spec.email = ["film42@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "FlameGraph profiler for JRuby"
|
13
|
+
spec.description = "FlameGraph profiler for JRuby"
|
14
|
+
spec.homepage = "https://github.com/film42/jruby-profiler-flame_graph_profile_printer"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.platform = "java"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "jruby/profiler"
|
2
|
+
|
3
|
+
# HACK: This hack is here so we can read the set of invocations from
|
4
|
+
# the InvocationSet class. We need this to follow the stack trace.
|
5
|
+
class ::Java::OrgJrubyRuntimeProfileBuiltin::InvocationSet
|
6
|
+
def get_invocations
|
7
|
+
field = ::Java::OrgJrubyRuntimeProfileBuiltin::InvocationSet.java_class.declared_field(:invocations)
|
8
|
+
field.accessible = true
|
9
|
+
field.value(self)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module JRuby
|
14
|
+
module Profiler
|
15
|
+
class FlameGraphProfilePrinter < ::Java::OrgJrubyRuntimeProfileBuiltin::ProfilePrinter
|
16
|
+
VERSION = "0.2.0"
|
17
|
+
|
18
|
+
def printHeader(out)
|
19
|
+
end
|
20
|
+
|
21
|
+
def printFooter(out)
|
22
|
+
end
|
23
|
+
|
24
|
+
def printProfile(out, is_first=false)
|
25
|
+
top_invocation = getTopInvocation
|
26
|
+
@methods = self.class.methodData(top_invocation)
|
27
|
+
thread_name = getThreadName()
|
28
|
+
prefix = ["Thread:#{thread_name}"]
|
29
|
+
print_invocation_stack(out, prefix, top_invocation)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def print_invocation_stack(out, prefix, invocation)
|
35
|
+
serial = invocation.getMethodSerialNumber
|
36
|
+
return if self.isThisProfilerInvocation(serial)
|
37
|
+
|
38
|
+
method_data = @methods.get(serial)
|
39
|
+
total_calls = method_data.totalCalls
|
40
|
+
|
41
|
+
path_calls = invocation.getCount
|
42
|
+
duration = invocation.getDuration / 1_000_000.0
|
43
|
+
|
44
|
+
method_name = self.methodName(serial)
|
45
|
+
name = "#{method_name} (#{path_calls}/#{total_calls})"
|
46
|
+
|
47
|
+
current = prefix + [name]
|
48
|
+
out.puts("#{current.join(";")} #{duration}")
|
49
|
+
|
50
|
+
invocation.children.entrySet.each do |entry|
|
51
|
+
child_invocation = entry.value
|
52
|
+
|
53
|
+
print_invocation_stack(out, current, child_invocation)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jruby-profiler-flame_graph_profile_printer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Garrett Thornburg
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.11'
|
19
|
+
name: bundler
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '10.0'
|
33
|
+
name: rake
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: FlameGraph profiler for JRuby
|
42
|
+
email:
|
43
|
+
- film42@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".travis.yml"
|
51
|
+
- CODE_OF_CONDUCT.md
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/console
|
57
|
+
- bin/setup
|
58
|
+
- example/powers.rb
|
59
|
+
- example1.png
|
60
|
+
- example2.png
|
61
|
+
- jruby-profiler-flame_graph_profile_printer.gemspec
|
62
|
+
- lib/jruby/profiler/flame_graph_profile_printer.rb
|
63
|
+
homepage: https://github.com/film42/jruby-profiler-flame_graph_profile_printer
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.4.8
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: FlameGraph profiler for JRuby
|
87
|
+
test_files: []
|