qprof 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/qprof/version.rb +1 -1
  3. data/lib/qprof.rb +10 -4
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 327742d10634cd1a5fe27eec465dbe7edd7d64fb48983a898a00c32c2cb09dfd
4
- data.tar.gz: 4c60c8563bb095496825124e73845ba2289c586dd275ea709cd91f079a6bacd6
3
+ metadata.gz: 7c67f1d968b42697cb0445f69199d6dbc62362802b261b22133c3d27b28fdcd7
4
+ data.tar.gz: 230ebd116a6c29191d3d88bbb5abe6b310d0fe9225cab19568b712c8aeee8f68
5
5
  SHA512:
6
- metadata.gz: 36105475ebb5fd15282b7af5896709904f1a68ac106483f7a90b7c656fc0d243bf7c640d57d02b14c5e12d79524a8d81fdeee950e5ee4a9225ff8c2c6314be4a
7
- data.tar.gz: 136a82998d683bd7c33172b13f595c587a9aa009de0c47857a6e1049800cb349918efb5b7b432bcd0cb964100dbc05006c0329c281325acc4f148a84fd81df54
6
+ metadata.gz: 994c3256c2f384cf5ac9c5ac13773e25835fd271b427e73a6a8800d55dfeb3a61a60236ce5d43b418e777934de6e8912fd949364776a4458ca3266b97210cb49
7
+ data.tar.gz: dd473f81ab60d8274d8c0944142e10dd5cea8f9b89a6e87e68fe57c0f9d8a9b08a0e1acaa7a19ab314ecbed872e3e6534843b4bac42a8f17b4426a98a85c0c0a
data/lib/qprof/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QProf
4
- VERSION = '1.0.1'
4
+ VERSION = '1.1.0'
5
5
  end
data/lib/qprof.rb CHANGED
@@ -16,21 +16,27 @@ module QProf
16
16
  run_svg_path = "/tmp/qprof/#{run}.svg"
17
17
  flamegraph_pl_path = '/tmp/qprof/FlameGraph/flamegraph.pl'
18
18
 
19
+ # pull flamegraph if it's needed
19
20
  `git clone https://github.com/brendangregg/FlameGraph.git #{File.dirname(flamegraph_pl_path)}` unless File.exist?(flamegraph_pl_path)
20
21
 
22
+ # run block
21
23
  @benchmark = Benchmark.measure do
22
24
  @result = RubyProf.profile do
23
- yield
25
+ @value = yield
24
26
  end
25
27
  end
26
28
 
27
- subtitle = %i[utime stime real]
28
- .map { |x| "#{x} = #{@benchmark.send(x).round(4)}s" }
29
- .join('; ')
29
+ # generate graph
30
+ subtitle = %i[utime stime real].map { |x| "#{x} = #{@benchmark.send(x).round(4)}s" }.join('; ')
30
31
  printer = RubyProf::FlameGraphPrinter.new(@result)
31
32
  File.open(run_txt_path, 'w') { |file| printer.print(file) }
32
33
  `cat #{run_txt_path} | #{flamegraph_pl_path} --title \"#{title}\" --subtitle \"#{subtitle}\" > #{run_svg_path}`
34
+
35
+ # open in browser
33
36
  Launchy.open(run_svg_path)
37
+
38
+ # return any wrapped value
39
+ @value
34
40
  end
35
41
  end
36
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - graham otte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-21 00:00:00.000000000 Z
11
+ date: 2023-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: securerandom
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.2.3
111
+ rubygems_version: 3.4.1
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: quick and dirty ruby flamegraphs