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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5d67e8ac138faae3a64a5dcfbf51e8884b7f2d1
4
- data.tar.gz: ccb8273915b075b0b8dec96618438038d269d314
3
+ metadata.gz: cf79c062e09422f12edf490b663ab78eb4bbde16
4
+ data.tar.gz: 80e3d804620ee77bdbb2362c3049b44d31811a4a
5
5
  SHA512:
6
- metadata.gz: 6a2c20570f872587c569853617f4f3400b6b4ca388996fe72182f2d3ee29504c7a679e5bc19bd1a539eac44a74eaf1d930278bc6ca6b403eef64413a33bbeccf
7
- data.tar.gz: 0eaeaf451efb07b4363f612a94ff153fa17b6a7ee2cec5965c19493e58d226835d7eca6103a616031f7b93d8d0cb9e799682fc0c48a03966ab35fafce9f5637a
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 System
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
- This is the sample usage of YarvProf in your code. YarvProf#start can take 2 keyword args, one is for the flag to switch measurement mode (:cpu or :wall), and the other one is to specify the target directory the dump file will be seved in.
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
- And this is the sample usage of yarv-prof CLI command, which is specifically designed to parse and view dumped data. yarv-prof command can take following options.
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
@@ -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
- @measure_mode = clock == :cpu ? "vtimestamp" : "timestamp"
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,#{@measure_mode}\\n");
15
+ printf("insn,#{measure_mode}\\n");
17
16
  }
18
17
 
19
18
  ruby#{Process.pid}:::insn{
20
- printf("%s,%d\\n", copyinstr(arg0), #{@measure_mode});
19
+ printf("%s,%d\\n", copyinstr(arg0), #{measure_mode});
21
20
  }
22
21
  EOS
23
22
  @file.close
24
- FileUtils.mkdir @dump_to if !File.directory?(@dump_to)
25
- dumpfile = Time.now.strftime('%Y%m%d_%H%M%S.dump')
26
- @pid = Process.spawn("dtrace -q -s '#{@file.path}'", :err => :out,:out => @dump_to + dumpfile)
27
- #while File.read(DUMPTO+dumpfile).size < 10 do
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
@@ -1,3 +1,3 @@
1
1
  class YarvProf
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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 = 'A DTrace-based YARV profiler'
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.0
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-28 00:00:00.000000000 Z
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: A DTrace-based YARV profiler
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