Module: RSpecTracer::Tracker::IOHooks::FileReads Private
- Defined in:
- lib/rspec_tracer/tracker/io_hooks/file.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Prepended onto File.singleton_class. Each method records the
path (IOHooks.record fast-rejects outside a bucketed example
and swallows any error) then forwards every argument + block
to super via (...).
The if Thread.current[BUCKET_KEY] guard is the hot-path
cut: FileReads sits in every File.singleton_class read on
the entire process for the life of the run, even between
examples and during boot. Without the guard each File.read
paid 2 method-dispatch frames + IOHooks._record's
@root_prefix nil-check before the inner bucket check could
bail. With the guard, the bucket check happens at FileReads
so the reject path skips IOHooks.record entirely. Cuts the
M2 Max reject overhead from ~530 ns/call to ~300 ns/call.
Instance Method Summary collapse
-
#binread(path) ⇒ Object
private
Internal method on the tracer pipeline.
-
#open(path) ⇒ Object
private
Internal method on the tracer pipeline.
-
#read(path) ⇒ Object
private
Internal method on the tracer pipeline.
-
#readlines(path) ⇒ Object
private
Internal method on the tracer pipeline.
Instance Method Details
#binread(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
34 35 36 37 |
# File 'lib/rspec_tracer/tracker/io_hooks/file.rb', line 34 def binread(path, ...) IOHooks.record(path) if Thread.current[BUCKET_KEY] super end |
#open(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
48 49 50 51 |
# File 'lib/rspec_tracer/tracker/io_hooks/file.rb', line 48 def open(path, ...) IOHooks.record(path) if Thread.current[BUCKET_KEY] super end |
#read(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
27 28 29 30 |
# File 'lib/rspec_tracer/tracker/io_hooks/file.rb', line 27 def read(path, ...) IOHooks.record(path) if Thread.current[BUCKET_KEY] super end |
#readlines(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
41 42 43 44 |
# File 'lib/rspec_tracer/tracker/io_hooks/file.rb', line 41 def readlines(path, ...) IOHooks.record(path) if Thread.current[BUCKET_KEY] super end |