Class: Mila::Benchmark::ReporterProxy
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Mila::Benchmark::ReporterProxy
- Defined in:
- lib/mila/benchmark/reporter_proxy.rb
Instance Method Summary collapse
-
#initialize(obj, yielder: nil) ⇒ ReporterProxy
constructor
A new instance of ReporterProxy.
- #report(name = "trial #{@count}", &block) ⇒ Object (also: #r)
Constructor Details
#initialize(obj, yielder: nil) ⇒ ReporterProxy
Returns a new instance of ReporterProxy.
4 5 6 7 8 |
# File 'lib/mila/benchmark/reporter_proxy.rb', line 4 def initialize(obj, yielder: nil) super(obj) @count = 1 @yielder = yielder end |
Instance Method Details
#report(name = "trial #{@count}", &block) ⇒ Object Also known as: r
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mila/benchmark/reporter_proxy.rb', line 10 def report(name = "trial #{@count}", &block) __getobj__.report(name) do begin result = block.call @yielder << result if @yielder rescue => e real_backtrace = e.backtrace.reject { |line| line =~ /lib\/mila/ } e.set_backtrace(real_backtrace) raise e end end @count += 1 end |