yarv-prof 0.1.0 → 0.1.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 +16 -3
- data/lib/yarv-prof.rb +9 -12
- data/lib/yarv-prof/version.rb +1 -1
- data/yarv-prof.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf79c062e09422f12edf490b663ab78eb4bbde16
|
4
|
+
data.tar.gz: 80e3d804620ee77bdbb2362c3049b44d31811a4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb7d594ca3f22fb6bb30276127b7cc062e5af4d53751d76142beaab9366a8ce4b86946b00721a51810a7238f997b355924f1933a673f77df494f78f8e7a71028
|
7
|
+
data.tar.gz: 98c58b317cc56144a2a3fc68de01e90a4be866a76a5c3fbc92a26dad9958a328dcf98dc9122f6f7597b38d43a874e6964da442ac7e511f7767c90c05ff7acbc9
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## Prerequisite
|
2
2
|
|
3
|
-
- DTrace must be installed on your
|
3
|
+
- DTrace must be installed on your system
|
4
4
|
- You need to edit MRI source code as follows(since pre-compiled MRI doesn't provide `insn` probe, you need to enable this manually, as of Ruby2.4.0)
|
5
5
|
|
6
6
|
```
|
@@ -40,21 +40,34 @@ branchunless 1(3%) 15042(1%) 15042
|
|
40
40
|
|
41
41
|
## Usage
|
42
42
|
|
43
|
+
#### Step1: Recording
|
44
|
+
|
45
|
+
This is the sample usage of YarvProf in your code.
|
46
|
+
|
43
47
|
```
|
44
48
|
YarvProf.start(clock: :cpu, out:'~/log/')
|
45
49
|
p :hello
|
46
50
|
YarvProf.end
|
47
51
|
```
|
48
52
|
|
49
|
-
|
53
|
+
YarvProf#start can take following 3 optional keyword args.
|
54
|
+
|
55
|
+
- `clock` is for the flag to switch measurement mode(`:cpu` or `:wall`)
|
56
|
+
- `out` is to specify the target directory path which the dump file will be stored in.
|
57
|
+
- `opt` is to give arbitrary CLI option when yarv-prof trigger dtrace command(e.g. `opt:'-x bufsize=20m'`).
|
58
|
+
|
59
|
+
#### Step2: Reporting
|
60
|
+
|
61
|
+
Here is the sample usage of yarv-prof CLI command, which is specifically designed to parse and view dumped data.
|
50
62
|
|
51
63
|
```
|
52
64
|
$ yarvprof --load ./result.dump --insn getlocal_OP__WC__1
|
53
65
|
```
|
54
66
|
|
55
|
-
|
67
|
+
yarv-prof command can take following options.
|
56
68
|
|
57
69
|
```
|
70
|
+
$ yarvprof -h
|
58
71
|
Usage: yarv-prof [options]
|
59
72
|
-v, --version Print version
|
60
73
|
--load=FILENAME Load .dump file
|
data/lib/yarv-prof.rb
CHANGED
@@ -3,34 +3,31 @@ require 'tempfile'
|
|
3
3
|
|
4
4
|
class YarvProf
|
5
5
|
class << self
|
6
|
-
def start(clock: :wall, out:'/tmp/yarv-prof/')
|
6
|
+
def start(clock: :wall, out:'/tmp/yarv-prof/', opt:'-x bufsize=20m')
|
7
7
|
at_exit do
|
8
8
|
Process.kill(:TERM, @pid) if !@pid.nil?
|
9
9
|
FileUtils.remove_entry @file.path if File.exists?(@file.path)
|
10
10
|
end
|
11
|
-
|
12
|
-
@dump_to = out
|
11
|
+
measure_mode = clock == :cpu ? "vtimestamp" : "timestamp"
|
13
12
|
@file = Tempfile.new('.yarv-prof.d')
|
14
13
|
@file.puts <<EOS
|
15
14
|
dtrace:::BEGIN{
|
16
|
-
printf("insn,#{
|
15
|
+
printf("insn,#{measure_mode}\\n");
|
17
16
|
}
|
18
17
|
|
19
18
|
ruby#{Process.pid}:::insn{
|
20
|
-
printf("%s,%d\\n", copyinstr(arg0), #{
|
19
|
+
printf("%s,%d\\n", copyinstr(arg0), #{measure_mode});
|
21
20
|
}
|
22
21
|
EOS
|
23
22
|
@file.close
|
24
|
-
FileUtils.mkdir
|
25
|
-
dumpfile = Time.now.strftime('%Y%m%d_%H%M%S.dump')
|
26
|
-
@pid = Process.spawn("dtrace -q -s '#{@file.path}'", :err => :out,:out =>
|
27
|
-
|
28
|
-
# sleep 0.01
|
29
|
-
#end
|
30
|
-
sleep 0.5
|
23
|
+
FileUtils.mkdir out if !File.directory?(out)
|
24
|
+
dumpfile = out + Time.now.strftime('%Y%m%d_%H%M%S.dump')
|
25
|
+
@pid = Process.spawn("dtrace -q -s '#{@file.path}' #{opt}", :err => :out,:out => dumpfile)
|
26
|
+
`size=0;while [ $size -le 10 ];do size=$(wc -c < #{dumpfile});sleep 0.01;done`
|
31
27
|
end
|
32
28
|
|
33
29
|
def end
|
30
|
+
sleep 1 # sleep here otherwise the log file will be empty
|
34
31
|
Process.kill(:TERM, @pid) if !@pid.nil?
|
35
32
|
end
|
36
33
|
end
|
data/lib/yarv-prof/version.rb
CHANGED
data/yarv-prof.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.executables = 'yarv-prof'
|
16
16
|
|
17
17
|
s.summary = 'A DTrace-based YARV profiler'
|
18
|
-
s.description = '
|
18
|
+
s.description = "yarv-prof does nothing special to profile YARV behavior, just heavily depends on Ruby's DTrace probes support. If you are looking for something useful to utilize Ruby's DTrace feature, yarv-prof may work for you."
|
19
19
|
s.license = 'MIT'
|
20
20
|
|
21
21
|
s.add_dependency "enumerable-statistics"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yarv-prof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kei Sawada(@remore)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: enumerable-statistics
|
@@ -24,7 +24,9 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description:
|
27
|
+
description: yarv-prof does nothing special to profile YARV behavior, just heavily
|
28
|
+
depends on Ruby's DTrace probes support. If you are looking for something useful
|
29
|
+
to utilize Ruby's DTrace feature, yarv-prof may work for you.
|
28
30
|
email: k@swd.cc
|
29
31
|
executables:
|
30
32
|
- yarv-prof
|