enhanced_errors 3.0.3 → 3.0.4

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
  SHA256:
3
- metadata.gz: f31d5706d675b416846c7fe44cc1c6f6eb405489d574a9e9578aebee106109af
4
- data.tar.gz: a5d31e4545534bfba158646f30d99bae1107086c51e20d1f8a5ad77454d74c23
3
+ metadata.gz: fcc0ec081a5d0c8971d430b9d87a241c5678d07037a661fc3202b9b5cc416840
4
+ data.tar.gz: c136809b9cb0927ec57f95df48a30020875dd0725c6c0efd3983235d8ae2cc82
5
5
  SHA512:
6
- metadata.gz: b79305f72e59ac8c615b137b6279c74d13156085d698bcc6efaf0d6c637bd489d6bfe1e93bfc1aede2673abe60033b3e64111b07b4916b4fe880f417684bfdbd
7
- data.tar.gz: 97c791940c780ee0952e82f256b640923ba59623052224ec0c3ca5d84bf57a471f349e281cea82c0f00976dbba497a62bdc39fa5f1115d655e96baa980d0215c
6
+ metadata.gz: 4d7c0b9e0ae3d02b32442b9a02c9c1b29f35051e2c0c4c9de085a60c11fa7d05b132602ebabfdc438f4721b579deefd561efa13c470324fa5ccd341015eabeee
7
+ data.tar.gz: b004525dd0f9dfa3327067b78b3cdf2a9db98bbfa75bd85dc348e220c7ab966d6b8360c0157e8bc23d39a8e8f65219e53c069ad242dda10cf83c5756e96fadf1
data/README.md CHANGED
@@ -33,7 +33,6 @@ end
33
33
  <img src="./doc/images/enhanced-spec.png" style="height: 369px; width: 712px;"></img>
34
34
 
35
35
 
36
-
37
36
  The RSpec test-time only approach constrained only to test-time.
38
37
 
39
38
  ### RSpec Setup
@@ -148,6 +147,7 @@ EnhancedErrors use-cases:
148
147
  * Handle CI failures faster by skipping reproduction steps.
149
148
  * Address elusive "Heisenbugs" by capturing error context preemptively.
150
149
  * Debug cron jobs and daemons with rich, failure-specific logs.
150
+ * LLM-food - Feed debug info with variables into an LLM, making state examine-able for it
151
151
 
152
152
  ## Installation
153
153
 
@@ -452,9 +452,10 @@ I would not enable it in production *yet*.
452
452
 
453
453
  ## Contributing
454
454
 
455
- Bug reports and pull requests are welcome on GitHub at [https://github.com/your_username/enhanced_errors](https://github.com/your_username/enhanced_errors).
455
+ Bug reports and pull requests are welcome on GitHub.
456
+
457
+ * Please include tests to demonstrate your contribution working.
456
458
 
457
459
  ## License
458
460
 
459
461
  The gem is available as open-source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
460
-
@@ -1,8 +1,15 @@
1
1
  require 'benchmark'
2
- require_relative '../lib/enhanced/enhanced' # Adjust the path if necessary
2
+ require_relative '../lib/enhanced_errors' # Adjust the path if necessary
3
+
4
+ #require 'profile'
5
+
6
+ # In general, the results of this are--catching exception bindings is pretty cheap.
7
+ # However, catching :call, :return, :b_return, :b_call are 100x more expensive.
8
+ # Makes sense if you think about the relative frequency of things.
9
+
3
10
 
4
11
  # Define the number of iterations
5
- ITERATIONS = 10_000
12
+ ITERATIONS = 1_000
6
13
  EXCEPTIONS_PER_BATCH = 100
7
14
 
8
15
  class Boo < StandardError; end
@@ -12,20 +19,8 @@ def calculate_cost(time_in_seconds)
12
19
  (milliseconds / (ITERATIONS / EXCEPTIONS_PER_BATCH)).round(2)
13
20
  end
14
21
 
15
- def with_enhanced_errors
16
- EnhancedErrors.enhance_exceptions!(debug: false)
17
- ITERATIONS.times do
18
- begin
19
- foo = 'bar'
20
- @boo = 'baz'
21
- raise 'Test exception with EnhancedErrors'
22
- rescue => e
23
- e.message
24
- end
25
- end
26
- end
27
22
 
28
- def without_enhanced_errors
23
+ def raise_errors
29
24
  ITERATIONS.times do
30
25
  begin
31
26
  foo = 'bar'
@@ -38,8 +33,9 @@ def without_enhanced_errors
38
33
  end
39
34
 
40
35
  def when_capture_only_regexp_matched
36
+ rxp = /Boo/
41
37
  EnhancedErrors.enhance_exceptions!(debug: false) do
42
- eligible_for_capture { |exception| !!/Boo/.match(exception.class.to_s) }
38
+ eligible_for_capture { |exception| !!rxp.match(exception.class.to_s) }
43
39
  end
44
40
 
45
41
  ITERATIONS.times do
@@ -54,8 +50,9 @@ def when_capture_only_regexp_matched
54
50
  end
55
51
 
56
52
  def when_capture_only_regexp_did_not_match
57
- EnhancedErrors.enhance_exceptions!(debug: false) do
58
- eligible_for_capture { |exception| !!/Baz/.match(exception.class.to_s) }
53
+ rxp = /Baz/
54
+ EnhancedErrors.enhance_exceptions!(override_messages: true) do
55
+ eligible_for_capture { |exception| !!rxp.match(exception.class.to_s) }
59
56
  end
60
57
 
61
58
  ITERATIONS.times do
@@ -71,18 +68,23 @@ end
71
68
 
72
69
  puts "Cost Exploration\n"
73
70
  Benchmark.bm(35) do |x|
74
- without_time = x.report('10k Without EnhancedErrors:') { without_enhanced_errors }
75
- with_time = x.report('10k With EnhancedErrors:') { with_enhanced_errors }
76
-
77
- puts "\nCost per 100 exceptions (Without EnhancedErrors): #{calculate_cost(without_time.real)} ms"
78
- puts "Cost per 100 exceptions (With EnhancedErrors): #{calculate_cost(with_time.real)} ms"
71
+ without_time = x.report('Baseline 1k (NO EnhancedErrors, tight error raise loop):') { raise_errors }
79
72
  end
80
73
 
81
- puts "\nProof that if you only match the classes you care about, the cost is nominal\n"
82
- Benchmark.bm(35) do |x|
83
- matched_time = x.report('10k With capture_only_regexp match:') { when_capture_only_regexp_matched }
84
- not_matched_time = x.report('10k Without capture_only_regexp match:') { when_capture_only_regexp_did_not_match }
74
+ puts "\n"
75
+ EnhancedErrors.enhance_exceptions!(debug: false)
85
76
 
86
- puts "\nCost per 100 exceptions (Capture Only Match): #{calculate_cost(matched_time.real)} ms"
87
- puts "Cost per 100 exceptions (No Match): #{calculate_cost(not_matched_time.real)} ms"
77
+ Benchmark.bm(35) do |x|
78
+ with_time = x.report('Stress 1k EnhancedErrors (Tight error raising loop w/ EnhancedErrors):') { raise_errors }
79
+ puts "Cost per 100 raised exceptions: #{calculate_cost(with_time.real)} ms"
88
80
  end
81
+
82
+
83
+ # puts "\nProof that if you only match the classes you care about, the cost is nominal\n"
84
+ # Benchmark.bm(35) do |x|
85
+ # matched_time = x.report('1k capture_only_regexp match (same as always-on) :') { when_capture_only_regexp_matched }
86
+ # not_matched_time = x.report('1k capture_only_regexp not matching (low-cost):') { when_capture_only_regexp_did_not_match }
87
+ #
88
+ # puts "\nCost per 100 exceptions (Capture Only Match): #{calculate_cost(matched_time.real)} ms"
89
+ # puts "Cost per 100 exceptions (No Match): #{calculate_cost(not_matched_time.real)} ms"
90
+ # end
@@ -71,7 +71,7 @@ def test_exception_with_large_variable(iterations, large_string)
71
71
  puts "Memory usage after exceptions: #{memory_usage} KB"
72
72
  end
73
73
 
74
- iterations = 10 # Adjust iterations as needed
74
+ iterations = 10000 # Adjust iterations as needed
75
75
 
76
76
  test_with_tracepoint(iterations, large_string)
77
77
  test_without_tracepoint(iterations, large_string)
@@ -0,0 +1,13 @@
1
+ Result from MacOs, Ruby 3.3.6 for benchmark.rb
2
+
3
+ --------------------------------------------
4
+
5
+ Cost Exploration
6
+ user system total real
7
+ Baseline 1k (NO EnhancedErrors, tight error raise loop): 0.000296 0.000040 0.000336 ( 0.000334)
8
+
9
+ Cost per 100 raised exceptions: 0.56 ms
10
+ user system total real
11
+ Stress 1k EnhancedErrors (Tight error raising loop w/ EnhancedErrors): 0.005498 0.000147 0.005645 ( 0.005647)
12
+
13
+
@@ -381,9 +381,9 @@
381
381
  </div>
382
382
 
383
383
  <div id="footer">
384
- Generated on Tue Dec 17 21:43:58 2024 by
384
+ Generated on Tue Dec 24 15:27:20 2024 by
385
385
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
386
- 0.9.37 (ruby-3.3.6).
386
+ 0.9.37 (ruby-3.1.3).
387
387
  </div>
388
388
 
389
389
  </div>
@@ -0,0 +1,283 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Enhanced::Context
8
+
9
+ &mdash; Documentation by YARD 0.9.37
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Enhanced::Context";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Enhanced.html" title="Enhanced (module)">Enhanced</a></span></span>
41
+ &raquo;
42
+ <span class="title">Context</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Enhanced::Context
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Enhanced::Context</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/enhanced/context.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+
103
+
104
+
105
+
106
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
107
+ <ul class="summary">
108
+
109
+ <li class="public ">
110
+ <span class="summary_signature">
111
+
112
+ <a href="#binding_infos-instance_method" title="#binding_infos (instance method)">#<strong>binding_infos</strong> &#x21d2; Object </a>
113
+
114
+
115
+
116
+ </span>
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+ <span class="summary_desc"><div class='inline'>
130
+ <p>Returns the value of attribute binding_infos.</p>
131
+ </div></span>
132
+
133
+ </li>
134
+
135
+
136
+ </ul>
137
+
138
+
139
+
140
+
141
+
142
+ <h2>
143
+ Instance Method Summary
144
+ <small><a href="#" class="summary_toggle">collapse</a></small>
145
+ </h2>
146
+
147
+ <ul class="summary">
148
+
149
+ <li class="public ">
150
+ <span class="summary_signature">
151
+
152
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> &#x21d2; Context </a>
153
+
154
+
155
+
156
+ </span>
157
+
158
+
159
+ <span class="note title constructor">constructor</span>
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+ <span class="summary_desc"><div class='inline'>
169
+ <p>A new instance of Context.</p>
170
+ </div></span>
171
+
172
+ </li>
173
+
174
+
175
+ </ul>
176
+
177
+
178
+ <div id="constructor_details" class="method_details_list">
179
+ <h2>Constructor Details</h2>
180
+
181
+ <div class="method_details first">
182
+ <h3 class="signature first" id="initialize-instance_method">
183
+
184
+ #<strong>initialize</strong> &#x21d2; <tt><span class='object_link'><a href="" title="Enhanced::Context (class)">Context</a></span></tt>
185
+
186
+
187
+
188
+
189
+
190
+ </h3><div class="docstring">
191
+ <div class="discussion">
192
+
193
+ <p>Returns a new instance of Context.</p>
194
+
195
+
196
+ </div>
197
+ </div>
198
+ <div class="tags">
199
+
200
+
201
+ </div><table class="source_code">
202
+ <tr>
203
+ <td>
204
+ <pre class="lines">
205
+
206
+
207
+ 5
208
+ 6
209
+ 7</pre>
210
+ </td>
211
+ <td>
212
+ <pre class="code"><span class="info file"># File 'lib/enhanced/context.rb', line 5</span>
213
+
214
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
215
+ <span class='ivar'>@binding_infos</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
216
+ <span class='kw'>end</span></pre>
217
+ </td>
218
+ </tr>
219
+ </table>
220
+ </div>
221
+
222
+ </div>
223
+
224
+ <div id="instance_attr_details" class="attr_details">
225
+ <h2>Instance Attribute Details</h2>
226
+
227
+
228
+ <span id="binding_infos=-instance_method"></span>
229
+ <div class="method_details first">
230
+ <h3 class="signature first" id="binding_infos-instance_method">
231
+
232
+ #<strong>binding_infos</strong> &#x21d2; <tt>Object</tt>
233
+
234
+
235
+
236
+
237
+
238
+ </h3><div class="docstring">
239
+ <div class="discussion">
240
+
241
+ <p>Returns the value of attribute binding_infos.</p>
242
+
243
+
244
+ </div>
245
+ </div>
246
+ <div class="tags">
247
+
248
+
249
+ </div><table class="source_code">
250
+ <tr>
251
+ <td>
252
+ <pre class="lines">
253
+
254
+
255
+ 3
256
+ 4
257
+ 5</pre>
258
+ </td>
259
+ <td>
260
+ <pre class="code"><span class="info file"># File 'lib/enhanced/context.rb', line 3</span>
261
+
262
+ <span class='kw'>def</span> <span class='id identifier rubyid_binding_infos'>binding_infos</span>
263
+ <span class='ivar'>@binding_infos</span>
264
+ <span class='kw'>end</span></pre>
265
+ </td>
266
+ </tr>
267
+ </table>
268
+ </div>
269
+
270
+ </div>
271
+
272
+
273
+ </div>
274
+
275
+ <div id="footer">
276
+ Generated on Tue Dec 24 15:27:20 2024 by
277
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
278
+ 0.9.37 (ruby-3.1.3).
279
+ </div>
280
+
281
+ </div>
282
+ </body>
283
+ </html>