qprof 1.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c67f1d968b42697cb0445f69199d6dbc62362802b261b22133c3d27b28fdcd7
4
- data.tar.gz: 230ebd116a6c29191d3d88bbb5abe6b310d0fe9225cab19568b712c8aeee8f68
3
+ metadata.gz: 2f4aa6886ff4e9e26d187f7fb25cfd12c981cdbe8c2c635903a73069a65d1478
4
+ data.tar.gz: 8ab18751feddb098e7e20b87b222cb5ac72a21a0f44438ba05ee662c5c9f9e31
5
5
  SHA512:
6
- metadata.gz: 994c3256c2f384cf5ac9c5ac13773e25835fd271b427e73a6a8800d55dfeb3a61a60236ce5d43b418e777934de6e8912fd949364776a4458ca3266b97210cb49
7
- data.tar.gz: dd473f81ab60d8274d8c0944142e10dd5cea8f9b89a6e87e68fe57c0f9d8a9b08a0e1acaa7a19ab314ecbed872e3e6534843b4bac42a8f17b4426a98a85c0c0a
6
+ metadata.gz: d001f15b9e92978bc201de55f6291cf3ab45ee4f1c59aa1e13f850127e9977ec9837c8d785cd3a47cb5ca66a297a04ef79846d8c760732d4cdd40a3a4f6eea3c
7
+ data.tar.gz: ca532e645bb7f075a8bd9fd99e4d15889d3f9d9e263b06e6d32de2a87541b11732590ba3a2807a37ca5f599860ee8f0b588f2b7347e9b0ffe12925bfaed65b3a
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.1.0'
4
+ VERSION = '3.0.0'
5
5
  end
data/lib/qprof.rb CHANGED
@@ -1,41 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'securerandom'
4
- require 'benchmark'
5
-
6
- require 'ruby-prof'
7
- require 'ruby-prof-flamegraph'
4
+ require 'stackprof'
8
5
  require 'launchy'
9
6
 
10
7
  module QProf
11
8
  class << self
12
- def call(title = 'Flame Graph')
9
+ def call(title = '')
13
10
  FileUtils.mkdir_p('/tmp/qprof')
14
11
  run = "#{Time.now.to_i}-#{SecureRandom.hex(4)}"
15
- run_txt_path = "/tmp/qprof/#{run}.txt"
16
- run_svg_path = "/tmp/qprof/#{run}.svg"
17
- flamegraph_pl_path = '/tmp/qprof/FlameGraph/flamegraph.pl'
18
-
19
- # pull flamegraph if it's needed
20
- `git clone https://github.com/brendangregg/FlameGraph.git #{File.dirname(flamegraph_pl_path)}` unless File.exist?(flamegraph_pl_path)
12
+ dump_path = "/tmp/qprof/#{run}.dump"
13
+ graph_path = "/tmp/qprof/#{run}.html"
21
14
 
22
- # run block
23
- @benchmark = Benchmark.measure do
24
- @result = RubyProf.profile do
25
- @value = yield
26
- end
15
+ StackProf.run(mode: :cpu, interval: 2, raw: true, out: dump_path) do
16
+ @value = yield
27
17
  end
28
18
 
29
- # generate graph
30
- subtitle = %i[utime stime real].map { |x| "#{x} = #{@benchmark.send(x).round(4)}s" }.join('; ')
31
- printer = RubyProf::FlameGraphPrinter.new(@result)
32
- File.open(run_txt_path, 'w') { |file| printer.print(file) }
33
- `cat #{run_txt_path} | #{flamegraph_pl_path} --title \"#{title}\" --subtitle \"#{subtitle}\" > #{run_svg_path}`
34
-
35
- # open in browser
36
- Launchy.open(run_svg_path)
19
+ flame_io = StringIO.new # hotman
20
+ StackProf::Report.from_file(dump_path).print_d3_flamegraph(flame_io)
21
+ File.write(graph_path, flame_io.string)
22
+ Launchy.open(graph_path)
37
23
 
38
- # return any wrapped value
39
24
  @value
40
25
  end
41
26
  end
data/qprof.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = QProf::VERSION
8
8
  spec.platform = Gem::Platform::RUBY
9
9
  spec.author = 'graham otte'
10
- spec.email = 'go@grahamotte.com'
10
+ spec.email = 'qprof@graham.lol'
11
11
  spec.description = 'quick and dirty ruby flamegraphs'
12
12
  spec.summary = spec.description
13
13
  spec.homepage = 'https://github.com/grahamotte/qprof'
@@ -15,8 +15,6 @@ Gem::Specification.new do |spec|
15
15
  spec.files = Dir['**/*'].select { |f| f[%r{^(lib/|.*gemspec)}] }
16
16
  spec.require_paths = ['lib']
17
17
  spec.add_dependency('securerandom')
18
- spec.add_dependency('benchmark')
19
- spec.add_dependency('ruby-prof')
20
- spec.add_dependency('ruby-prof-flamegraph')
18
+ spec.add_dependency('stackprof')
21
19
  spec.add_dependency('launchy')
22
20
  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.1.0
4
+ version: 3.0.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: 2023-03-24 00:00:00.000000000 Z
11
+ date: 2025-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: securerandom
@@ -25,35 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: benchmark
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: ruby-prof
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: ruby-prof-flamegraph
28
+ name: stackprof
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - ">="
@@ -81,7 +53,7 @@ dependencies:
81
53
  - !ruby/object:Gem::Version
82
54
  version: '0'
83
55
  description: quick and dirty ruby flamegraphs
84
- email: go@grahamotte.com
56
+ email: qprof@graham.lol
85
57
  executables: []
86
58
  extensions: []
87
59
  extra_rdoc_files: []