stackprof-run 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/exe/stackprof-run +60 -28
- data/lib/stackprof/run/version.rb +1 -1
- data/stackprof-run.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 143390d783d006f15b7393c89ebae02fd7acbcd21553e917175e96ece2983e2c
|
4
|
+
data.tar.gz: 8636d68289c4fbf75063f50c36a8f8fd91f4e27b30dc184b48c644787cec4dec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d185403afaf176507dcf47100a52ff794edf7d2c0b9c19b96b09fe73d39c6130d942adf9c76eb9e9aaa5291f14f26debf468c0619adb9a4015f9536c4b037a6
|
7
|
+
data.tar.gz: 44d6424601a697ffeb6f0a1b03a52ccc438a7c835cf9bb323fb6f5ed727c55f3ff6018dc33232503e529d81e03737b425b53969771974d707d11daa7e20e74b6
|
data/exe/stackprof-run
CHANGED
@@ -3,39 +3,71 @@
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'stackprof'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
opt.banner = 'Usage: stackprof-run [options] command [command options]'
|
15
|
-
opt.on('-m MODE', '--mode=MODE', ':cpu(default), :wall, :object'
|
16
|
-
opt.on('-o FILE', '--out=FILE', 'Output file name. (default: stackprof-out)')
|
17
|
-
opt.on('-i INTERVAL', '--interval=INTERVAL'
|
18
|
-
opt.on('-no-aggregate')
|
19
|
-
opt.on('-r', '--raw')
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
def main
|
7
|
+
opt = OptionParser.new
|
8
|
+
|
9
|
+
params = {
|
10
|
+
mode: ENV['STACKPROF_MODE']&.to_sym || :cpu,
|
11
|
+
out: ENV['STACKPROF_OUT'] || 'stackprof-out'
|
12
|
+
}
|
13
|
+
|
14
|
+
opt.banner = 'Usage: stackprof-run [options] command [command options]'
|
15
|
+
opt.on('-m MODE', '--mode=MODE', ':cpu(default), :wall, :object', &:to_sym)
|
16
|
+
opt.on('-o FILE', '--out=FILE', 'Output file name. (default: stackprof-out)')
|
17
|
+
opt.on('-i INTERVAL', '--interval=INTERVAL', &:to_i)
|
18
|
+
opt.on('-no-aggregate')
|
19
|
+
opt.on('-r', '--raw')
|
20
|
+
opt.on('-e command')
|
21
|
+
|
22
|
+
opt.order!(ARGV, into: params)
|
23
|
+
|
24
|
+
if params[:e]
|
25
|
+
exec_code params
|
26
|
+
else
|
27
|
+
exec_command opt, params
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
|
-
|
31
|
+
def exec_command(opt, params)
|
32
|
+
cmd = ARGV.shift
|
33
|
+
unless cmd
|
34
|
+
puts opt.help
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
|
38
|
+
path =
|
39
|
+
if File.exist?(cmd)
|
40
|
+
cmd
|
41
|
+
else
|
42
|
+
`which #{cmd}`.chomp
|
43
|
+
end
|
30
44
|
|
31
|
-
$PROGRAM_NAME = cmd
|
45
|
+
$PROGRAM_NAME = cmd
|
32
46
|
|
33
|
-
|
34
|
-
StackProf.run(mode: mode, out: out, interval: interval, aggregate: aggregate, raw: raw) do
|
35
|
-
begin
|
47
|
+
exec(params) do
|
36
48
|
load path
|
37
|
-
rescue Exception => ex
|
38
49
|
end
|
39
50
|
end
|
40
51
|
|
41
|
-
|
52
|
+
def exec_code(params)
|
53
|
+
exec(params) do
|
54
|
+
eval params[:e]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def exec(params)
|
59
|
+
opt = params.slice(:mode, :out, :interval, :raw).tap do |o|
|
60
|
+
o[:aggregate] = !!params[:'no-aggregate']
|
61
|
+
end
|
62
|
+
ex = nil
|
63
|
+
StackProf.run(opt) do
|
64
|
+
begin
|
65
|
+
yield
|
66
|
+
rescue Exception => ex
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
raise ex if ex
|
71
|
+
end
|
72
|
+
|
73
|
+
main
|
data/stackprof-run.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackprof-run
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stackprof
|
@@ -83,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
83
|
requirements:
|
84
84
|
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: 2.
|
86
|
+
version: 2.4.0
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - ">="
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
93
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.7.7
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: Run a ruby script with stackprof.
|