vernier 1.4.0 → 1.6.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.
@@ -1,14 +1,9 @@
1
1
  module Vernier
2
2
  class Result
3
- def stack_table=(stack_table)
4
- @stack_table = stack_table
5
- end
6
-
7
- def _stack_table
8
- @stack_table
9
- end
3
+ attr_accessor :stack_table
4
+ alias _stack_table stack_table
10
5
 
11
- attr_reader :markers
6
+ attr_reader :gc_markers
12
7
 
13
8
  attr_accessor :hooks
14
9
 
@@ -60,91 +55,8 @@ module Vernier
60
55
  end
61
56
  end
62
57
 
63
- class BaseType
64
- attr_reader :result, :idx
65
- def initialize(result, idx)
66
- @result = result
67
- @idx = idx
68
- end
69
-
70
- def to_s
71
- idx.to_s
72
- end
73
-
74
- def inspect
75
- "#<#{self.class}\n#{to_s}>"
76
- end
77
- end
78
-
79
- class Func < BaseType
80
- def label
81
- result._stack_table.func_name(idx)
82
- end
83
- alias name label
84
-
85
- def filename
86
- result._stack_table.func_filename(idx)
87
- end
88
-
89
- def to_s
90
- "#{name} at #{filename}"
91
- end
92
- end
93
-
94
- class Frame < BaseType
95
- def label; func.label; end
96
- def filename; func.filename; end
97
- alias name label
98
-
99
- def func
100
- func_idx = result._stack_table.frame_func_idx(idx)
101
- Func.new(result, func_idx)
102
- end
103
-
104
- def line
105
- result._stack_table.frame_line_no(idx)
106
- end
107
-
108
- def to_s
109
- "#{func}:#{line}"
110
- end
111
- end
112
-
113
- class Stack < BaseType
114
- def each_frame
115
- return enum_for(__method__) unless block_given?
116
-
117
- stack_idx = idx
118
- while stack_idx
119
- frame_idx = result._stack_table.stack_frame_idx(stack_idx)
120
- yield Frame.new(result, frame_idx)
121
- stack_idx = result._stack_table.stack_parent_idx(stack_idx)
122
- end
123
- end
124
-
125
- def leaf_frame_idx
126
- result._stack_table.stack_frame_idx(idx)
127
- end
128
-
129
- def leaf_frame
130
- Frame.new(result, leaf_frame_idx)
131
- end
132
-
133
- def frames
134
- each_frame.to_a
135
- end
136
-
137
- def to_s
138
- arr = []
139
- each_frame do |frame|
140
- arr << frame.to_s
141
- end
142
- arr.join("\n")
143
- end
144
- end
145
-
146
58
  def stack(idx)
147
- Stack.new(self, idx)
59
+ stack_table.stack(idx)
148
60
  end
149
61
 
150
62
  def total_bytes
@@ -1,46 +1,7 @@
1
+ require_relative "stack_table_helpers"
2
+
1
3
  module Vernier
2
4
  class StackTable
3
- def inspect
4
- "#<#{self.class.name} #{stack_count} stacks, #{frame_count} frames, #{func_count} funcs>"
5
- end
6
-
7
- def to_h
8
- {
9
- stack_table: {
10
- parent: stack_count.times.map { stack_parent_idx(_1) },
11
- frame: stack_count.times.map { stack_frame_idx(_1) }
12
- },
13
- frame_table: {
14
- func: frame_count.times.map { frame_func_idx(_1) },
15
- line: frame_count.times.map { frame_line_no(_1) }
16
- },
17
- func_table: {
18
- name: func_count.times.map { func_name(_1) },
19
- filename: func_count.times.map { func_filename(_1) },
20
- first_line: func_count.times.map { func_first_lineno(_1) }
21
- }
22
- }
23
- end
24
-
25
- def backtrace(stack_idx)
26
- full_stack(stack_idx).map do |stack_idx|
27
- frame_idx = stack_frame_idx(stack_idx)
28
- func_idx = frame_func_idx(frame_idx)
29
- line = frame_line_no(frame_idx)
30
- name = func_name(func_idx);
31
- filename = func_filename(func_idx);
32
-
33
- "#{filename}:#{line}:in '#{name}'"
34
- end
35
- end
36
-
37
- def full_stack(stack_idx)
38
- full_stack = []
39
- while stack_idx
40
- full_stack << stack_idx
41
- stack_idx = stack_parent_idx(stack_idx)
42
- end
43
- full_stack
44
- end
5
+ include StackTableHelpers
45
6
  end
46
7
  end
@@ -0,0 +1,140 @@
1
+ module Vernier
2
+ module StackTableHelpers
3
+ def inspect
4
+ "#<#{self.class.name} #{stack_count} stacks, #{frame_count} frames, #{func_count} funcs>"
5
+ end
6
+
7
+ def to_h
8
+ {
9
+ stack_table: {
10
+ parent: stack_count.times.map { stack_parent_idx(_1) },
11
+ frame: stack_count.times.map { stack_frame_idx(_1) }
12
+ },
13
+ frame_table: {
14
+ func: frame_count.times.map { frame_func_idx(_1) },
15
+ line: frame_count.times.map { frame_line_no(_1) }
16
+ },
17
+ func_table: {
18
+ name: func_count.times.map { func_name(_1) },
19
+ filename: func_count.times.map { func_filename(_1) },
20
+ first_line: func_count.times.map { func_first_lineno(_1) }
21
+ }
22
+ }
23
+ end
24
+
25
+ def backtrace(stack_idx)
26
+ full_stack(stack_idx).map do |stack_idx|
27
+ frame_idx = stack_frame_idx(stack_idx)
28
+ func_idx = frame_func_idx(frame_idx)
29
+ line = frame_line_no(frame_idx)
30
+ name = func_name(func_idx);
31
+ filename = func_filename(func_idx);
32
+
33
+ "#{filename}:#{line}:in '#{name}'"
34
+ end
35
+ end
36
+
37
+ def full_stack(stack_idx)
38
+ full_stack = []
39
+ while stack_idx
40
+ full_stack << stack_idx
41
+ stack_idx = stack_parent_idx(stack_idx)
42
+ end
43
+ full_stack
44
+ end
45
+
46
+ class BaseType
47
+ attr_reader :stack_table, :idx
48
+ def initialize(stack_table, idx)
49
+ @stack_table = stack_table
50
+ @idx = idx
51
+ end
52
+
53
+ def inspect
54
+ "#<#{self.class}\n#{to_s}>"
55
+ end
56
+ end
57
+
58
+ class Func < BaseType
59
+ def label
60
+ stack_table.func_name(idx)
61
+ end
62
+ alias name label
63
+
64
+ def filename
65
+ stack_table.func_filename(idx)
66
+ end
67
+
68
+ def to_s
69
+ "#{name} at #{filename}"
70
+ end
71
+ end
72
+
73
+ class Frame < BaseType
74
+ def label; func.label; end
75
+ def filename; func.filename; end
76
+ alias name label
77
+
78
+ def func
79
+ func_idx = stack_table.frame_func_idx(idx)
80
+ Func.new(stack_table, func_idx)
81
+ end
82
+
83
+ def line
84
+ stack_table.frame_line_no(idx)
85
+ end
86
+
87
+ def to_s
88
+ "#{func}:#{line}"
89
+ end
90
+ end
91
+
92
+ class Stack < BaseType
93
+ def each
94
+ return enum_for(__method__) unless block_given?
95
+
96
+ stack_idx = idx
97
+ while stack_idx
98
+ frame_idx = stack_table.stack_frame_idx(stack_idx)
99
+ yield Frame.new(stack_table, frame_idx)
100
+ stack_idx = stack_table.stack_parent_idx(stack_idx)
101
+ end
102
+ end
103
+ alias each_frame each
104
+
105
+ def [](n)
106
+ raise RangeError if n < 0
107
+ stack_idx = idx
108
+ while n > 0
109
+ stack_idx = stack_table.stack_parent_idx(stack_idx)
110
+ n -= 1
111
+ end
112
+ Frame.new(stack_table, stack_table.stack_frame_idx(stack_idx))
113
+ end
114
+
115
+ def leaf_frame_idx
116
+ stack_table.stack_frame_idx(idx)
117
+ end
118
+
119
+ def leaf_frame
120
+ Frame.new(stack_table, leaf_frame_idx)
121
+ end
122
+
123
+ def frames
124
+ each_frame.to_a
125
+ end
126
+
127
+ def to_s
128
+ arr = []
129
+ each_frame do |frame|
130
+ arr << frame.to_s
131
+ end
132
+ arr.join("\n")
133
+ end
134
+ end
135
+
136
+ def stack(idx)
137
+ Stack.new(self, idx)
138
+ end
139
+ end
140
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vernier
4
- VERSION = "1.4.0"
4
+ VERSION = "1.6.0"
5
5
  end
data/lib/vernier.rb CHANGED
@@ -3,11 +3,14 @@
3
3
  require_relative "vernier/version"
4
4
  require_relative "vernier/collector"
5
5
  require_relative "vernier/stack_table"
6
+ require_relative "vernier/parsed_profile"
6
7
  require_relative "vernier/result"
7
8
  require_relative "vernier/hooks"
8
9
  require_relative "vernier/vernier"
9
10
  require_relative "vernier/output/firefox"
10
11
  require_relative "vernier/output/top"
12
+ require_relative "vernier/output/file_listing"
13
+ require_relative "vernier/output/filename_filter"
11
14
 
12
15
  module Vernier
13
16
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vernier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-11-26 00:00:00.000000000 Z
10
+ date: 2025-03-22 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -70,6 +69,7 @@ files:
70
69
  - bin/console
71
70
  - bin/setup
72
71
  - bin/vernier
72
+ - examples/fiber_stalls.rb
73
73
  - examples/gvl_sleep.rb
74
74
  - examples/measure_overhead.rb
75
75
  - examples/minitest.rb
@@ -78,7 +78,11 @@ files:
78
78
  - examples/threaded_http_requests.rb
79
79
  - exe/vernier
80
80
  - ext/vernier/extconf.rb
81
+ - ext/vernier/memory.cc
82
+ - ext/vernier/periodic_thread.hh
81
83
  - ext/vernier/ruby_type_names.h
84
+ - ext/vernier/signal_safe_semaphore.hh
85
+ - ext/vernier/timestamp.hh
82
86
  - ext/vernier/vernier.cc
83
87
  - ext/vernier/vernier.hh
84
88
  - lib/vernier.rb
@@ -86,12 +90,17 @@ files:
86
90
  - lib/vernier/collector.rb
87
91
  - lib/vernier/hooks.rb
88
92
  - lib/vernier/hooks/active_support.rb
93
+ - lib/vernier/hooks/memory_usage.rb
89
94
  - lib/vernier/marker.rb
90
95
  - lib/vernier/middleware.rb
96
+ - lib/vernier/output/file_listing.rb
97
+ - lib/vernier/output/filename_filter.rb
91
98
  - lib/vernier/output/firefox.rb
92
99
  - lib/vernier/output/top.rb
100
+ - lib/vernier/parsed_profile.rb
93
101
  - lib/vernier/result.rb
94
102
  - lib/vernier/stack_table.rb
103
+ - lib/vernier/stack_table_helpers.rb
95
104
  - lib/vernier/thread_names.rb
96
105
  - lib/vernier/version.rb
97
106
  - vernier.gemspec
@@ -102,7 +111,6 @@ metadata:
102
111
  homepage_uri: https://github.com/jhawthorn/vernier
103
112
  source_code_uri: https://github.com/jhawthorn/vernier
104
113
  changelog_uri: https://github.com/jhawthorn/vernier
105
- post_install_message:
106
114
  rdoc_options: []
107
115
  require_paths:
108
116
  - lib
@@ -117,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
125
  - !ruby/object:Gem::Version
118
126
  version: '0'
119
127
  requirements: []
120
- rubygems_version: 3.5.22
121
- signing_key:
128
+ rubygems_version: 3.6.2
122
129
  specification_version: 4
123
130
  summary: A next generation CRuby profiler
124
131
  test_files: []