vernier 0.5.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/vernier.rb CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  require_relative "vernier/version"
4
4
  require_relative "vernier/collector"
5
+ require_relative "vernier/stack_table"
5
6
  require_relative "vernier/result"
7
+ require_relative "vernier/hooks"
6
8
  require_relative "vernier/vernier"
7
9
  require_relative "vernier/output/firefox"
8
10
  require_relative "vernier/output/top"
@@ -10,8 +12,10 @@ require_relative "vernier/output/top"
10
12
  module Vernier
11
13
  class Error < StandardError; end
12
14
 
13
- def self.trace(mode: :wall, out: nil, interval: nil)
14
- collector = Vernier::Collector.new(mode, { interval: })
15
+ autoload :Middleware, "vernier/middleware"
16
+
17
+ def self.profile(mode: :wall, **collector_options)
18
+ collector = Vernier::Collector.new(mode, collector_options)
15
19
  collector.start
16
20
 
17
21
  result = nil
@@ -19,33 +23,43 @@ module Vernier
19
23
  yield collector
20
24
  ensure
21
25
  result = collector.stop
22
- if out
23
- File.write(out, Output::Firefox.new(result).output)
24
- end
25
26
  end
26
27
 
27
28
  result
28
29
  end
29
30
 
30
- def self.trace_retained(out: nil, gc: true)
31
- 3.times { GC.start } if gc
31
+ class << self
32
+ alias_method :trace, :profile
33
+ alias_method :run, :profile
34
+ end
32
35
 
33
- collector = Vernier::Collector.new(:retained)
34
- collector.start
36
+ @collector = nil
35
37
 
36
- result = nil
37
- begin
38
- yield collector
39
- ensure
40
- result = collector.stop
41
- end
38
+ def self.start_profile(mode: :wall, **collector_options)
39
+ if @collector
40
+ @collector.stop
41
+ @collector = nil
42
42
 
43
- if out
44
- result.write(out:)
43
+ raise "Profile already started, stopping..."
45
44
  end
45
+
46
+ @collector = Vernier::Collector.new(mode, collector_options)
47
+ @collector.start
48
+ end
49
+
50
+ def self.stop_profile
51
+ raise "No profile started" unless @collector
52
+
53
+ result = @collector.stop
54
+ @collector = nil
55
+
46
56
  result
47
57
  end
48
58
 
59
+ def self.trace_retained(out: nil, gc: true, &block)
60
+ profile(mode: :retained, out:, gc:, &block)
61
+ end
62
+
49
63
  class Collector
50
64
  def self.new(mode, options = {})
51
65
  _new(mode, options)
data/vernier.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["John Hawthorn"]
9
9
  spec.email = ["john@hawthorn.email"]
10
10
 
11
- spec.summary = "An experimental profiler"
12
- spec.description = spec.summary
11
+ spec.summary = "A next generation CRuby profiler"
12
+ spec.description = "Next-generation Ruby 3.2.1+ sampling profiler. Tracks multiple threads, GVL activity, GC pauses, idle time, and more."
13
13
  spec.homepage = "https://github.com/jhawthorn/vernier"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 3.2.1"
@@ -29,4 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
  spec.extensions = ["ext/vernier/extconf.rb"]
32
+
33
+ spec.add_development_dependency "activesupport"
34
+ spec.add_development_dependency "rack"
32
35
  end
metadata CHANGED
@@ -1,16 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vernier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-28 00:00:00.000000000 Z
12
- dependencies: []
13
- description: An experimental profiler
11
+ date: 2024-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Next-generation Ruby 3.2.1+ sampling profiler. Tracks multiple threads,
42
+ GVL activity, GC pauses, idle time, and more.
14
43
  email:
15
44
  - john@hawthorn.email
16
45
  executables:
@@ -27,6 +56,8 @@ files:
27
56
  - bin/console
28
57
  - bin/setup
29
58
  - bin/vernier
59
+ - examples/gvl_sleep.rb
60
+ - examples/measure_overhead.rb
30
61
  - examples/minitest.rb
31
62
  - examples/ractor.rb
32
63
  - examples/rails.rb
@@ -39,10 +70,15 @@ files:
39
70
  - lib/vernier.rb
40
71
  - lib/vernier/autorun.rb
41
72
  - lib/vernier/collector.rb
73
+ - lib/vernier/hooks.rb
74
+ - lib/vernier/hooks/active_support.rb
42
75
  - lib/vernier/marker.rb
76
+ - lib/vernier/middleware.rb
43
77
  - lib/vernier/output/firefox.rb
44
78
  - lib/vernier/output/top.rb
45
79
  - lib/vernier/result.rb
80
+ - lib/vernier/stack_table.rb
81
+ - lib/vernier/thread_names.rb
46
82
  - lib/vernier/version.rb
47
83
  - vernier.gemspec
48
84
  homepage: https://github.com/jhawthorn/vernier
@@ -67,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
103
  - !ruby/object:Gem::Version
68
104
  version: '0'
69
105
  requirements: []
70
- rubygems_version: 3.5.3
106
+ rubygems_version: 3.4.19
71
107
  signing_key:
72
108
  specification_version: 4
73
- summary: An experimental profiler
109
+ summary: A next generation CRuby profiler
74
110
  test_files: []