singed 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/singed/cli.rb +13 -3
- data/lib/singed/kernel_ext.rb +3 -3
- data/lib/singed.rb +2 -2
- data/singed.gemspec +4 -5
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccc937a4dae7308cce56944f95e632c8e1001d7e2d51e148c7c24bab8ebb7e0a
|
4
|
+
data.tar.gz: 3bc4cbfad22a829baf1f973b23188442a9525c000554f6485b314641ce459988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8838d8a8b85fec579494d7a364a6f82d0a5a12245d076206a68d80264eacb01d43f1c6eb05c3258cf68c2d98f94caa160670f23d49e997b7c3ebd182028d8f99
|
7
|
+
data.tar.gz: c6effbd5a23d9df99c6d19516638c730bbdfc9be400f8d0e673b2d3a06c1144dc33470a18f3ff68d67bdce8242791792fdf6ee3dee78dcbf60292fed29970f28
|
data/README.md
CHANGED
@@ -12,6 +12,8 @@ gem "singed"
|
|
12
12
|
|
13
13
|
Then run `bundle install`
|
14
14
|
|
15
|
+
Then run `npm install -g speedscope`
|
16
|
+
|
15
17
|
## Usage
|
16
18
|
|
17
19
|
Simplest is calling with a block:
|
@@ -32,7 +34,7 @@ Singed.output_directory = "tmp/slowness-exploration"
|
|
32
34
|
If you are calling it in a loop, or with different variations, you can include a label on the filename:
|
33
35
|
|
34
36
|
```ruby
|
35
|
-
flamegraph(
|
37
|
+
flamegraph("rspec") {
|
36
38
|
# your code here
|
37
39
|
}
|
38
40
|
```
|
data/lib/singed/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'shellwords'
|
2
2
|
require 'tmpdir'
|
3
3
|
require 'optionparser'
|
4
|
+
require 'pathname'
|
4
5
|
|
5
6
|
# NOTE: we defer requiring singed until we run. that lets Rails load it if its in the gemfile, so the railtie has had a chance to run
|
6
7
|
|
@@ -64,6 +65,7 @@ module Singed
|
|
64
65
|
|
65
66
|
Singed.output_directory = @output_directory if @output_directory
|
66
67
|
Singed.output_directory ||= Dir.tmpdir
|
68
|
+
FileUtils.mkdir_p Singed.output_directory
|
67
69
|
@filename = Singed::Flamegraph.generate_filename(label: 'cli')
|
68
70
|
|
69
71
|
options = {
|
@@ -86,11 +88,19 @@ module Singed
|
|
86
88
|
prompt_password
|
87
89
|
end
|
88
90
|
|
89
|
-
|
91
|
+
rbspy = lambda do
|
90
92
|
# don't run things with spring, because it forks and rbspy won't see it
|
91
93
|
sudo ['rbspy', *rbspy_args], reason: 'Singed needs to run as root, but will drop permissions back to your user.', env: { 'DISABLE_SPRING' => '1' }
|
92
94
|
end
|
93
95
|
|
96
|
+
if defined?(Bundler)
|
97
|
+
Bundler.with_unbundled_env do
|
98
|
+
rbspy.call
|
99
|
+
end
|
100
|
+
else
|
101
|
+
rbspy.call
|
102
|
+
end
|
103
|
+
|
94
104
|
unless filename.exist?
|
95
105
|
puts "#{filename} doesn't exist. Maybe rbspy had a failure capturing it? Check the scrollback."
|
96
106
|
exit 1
|
@@ -102,9 +112,9 @@ module Singed
|
|
102
112
|
end
|
103
113
|
|
104
114
|
# clean the report, similar to how Singed::Report does
|
105
|
-
json = JSON.parse(filename.read)
|
115
|
+
json = JSON.parse(filename.read)
|
106
116
|
json['shared']['frames'].each do |frame|
|
107
|
-
frame[
|
117
|
+
frame['file'] = Singed.filter_line(frame['file'])
|
108
118
|
end
|
109
119
|
filename.write(JSON.dump(json))
|
110
120
|
|
data/lib/singed/kernel_ext.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
module Kernel
|
2
|
-
def flamegraph(label = nil, open: true, ignore_gc: false, interval: 1000, &block)
|
2
|
+
def flamegraph(label = nil, open: true, ignore_gc: false, interval: 1000, io: $stdout, &block)
|
3
3
|
fg = Singed::Flamegraph.new(label: label, ignore_gc: ignore_gc, interval: interval)
|
4
4
|
result = fg.record(&block)
|
5
5
|
fg.save
|
6
6
|
|
7
7
|
if open
|
8
8
|
# use npx, so we don't have to add it as a dependency
|
9
|
-
puts "🔥📈 #{'Captured flamegraph, opening with'.colorize(:bold).colorize(:red)}: #{fg.open_command}"
|
9
|
+
io.puts "🔥📈 #{'Captured flamegraph, opening with'.colorize(:bold).colorize(:red)}: #{fg.open_command}"
|
10
10
|
fg.open
|
11
11
|
else
|
12
|
-
puts "🔥📈 #{'Captured flamegraph to file'.colorize(:bold).colorize(:red)}: #{fg.filename}"
|
12
|
+
io.puts "🔥📈 #{'Captured flamegraph to file'.colorize(:bold).colorize(:red)}: #{fg.filename}"
|
13
13
|
end
|
14
14
|
|
15
15
|
result
|
data/lib/singed.rb
CHANGED
@@ -13,7 +13,7 @@ module Singed
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.output_directory
|
16
|
-
@output_directory
|
16
|
+
@output_directory
|
17
17
|
end
|
18
18
|
|
19
19
|
def enabled=(enabled)
|
@@ -53,4 +53,4 @@ end
|
|
53
53
|
|
54
54
|
require 'singed/kernel_ext'
|
55
55
|
require 'singed/railtie' if defined?(Rails::Railtie)
|
56
|
-
require 'singed/rspec' if defined?(RSpec)
|
56
|
+
require 'singed/rspec' if defined?(RSpec) && RSpec.respond_to?(:configure)
|
data/singed.gemspec
CHANGED
@@ -3,25 +3,24 @@
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'singed'
|
5
5
|
|
6
|
-
spec.version = '0.
|
6
|
+
spec.version = '0.2.1'
|
7
|
+
spec.license = 'MIT'
|
7
8
|
spec.authors = ['Josh Nichols']
|
8
9
|
spec.email = ['josh.nichols@gusto.com']
|
9
10
|
|
10
11
|
spec.summary = 'Quick and easy way to get flamegraphs from a specific part of your code base'
|
11
12
|
spec.required_ruby_version = '>= 2.7.0'
|
12
13
|
|
13
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to your gem server 'https://example.com'"
|
14
|
-
|
15
14
|
spec.files = Dir['README.md', '*.gemspec', 'lib/**/*', 'exe/**/*']
|
16
15
|
spec.bindir = 'exe'
|
17
16
|
spec.executables = spec.files.grep(%r(\Aexe/)) { |f| File.basename(f) }
|
18
17
|
spec.require_paths = ['lib']
|
19
18
|
|
20
|
-
# Uncomment to register a new dependency of your gem
|
21
19
|
spec.add_dependency 'colorize'
|
22
|
-
spec.add_dependency 'stackprof'
|
20
|
+
spec.add_dependency 'stackprof', '>= 0.2.13'
|
23
21
|
|
24
22
|
spec.add_development_dependency 'rake', '~> 13.0'
|
23
|
+
spec.add_development_dependency 'rspec'
|
25
24
|
|
26
25
|
# For more information and examples about making a new gem, checkout our
|
27
26
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.2.13
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.2.13
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
- josh.nichols@gusto.com
|
@@ -74,7 +88,8 @@ files:
|
|
74
88
|
- lib/singed/rspec.rb
|
75
89
|
- singed.gemspec
|
76
90
|
homepage:
|
77
|
-
licenses:
|
91
|
+
licenses:
|
92
|
+
- MIT
|
78
93
|
metadata: {}
|
79
94
|
post_install_message:
|
80
95
|
rdoc_options: []
|