lib/iev/profiler.rb in iev-0.3.4 vs lib/iev/profiler.rb in iev-0.3.5

- old
+ new

@@ -1,31 +1,31 @@ # frozen_string_literal: true # (c) Copyright 2020 Ribose Inc. # -module IEV +module Iev class Profiler attr_reader :bench, :dir, :prefix, :profile - def self.measure(prefix = nil, &block) - new(prefix).run(&block) + def self.measure(prefix = nil, &) + new(prefix).run(&) end def initialize(prefix, dir: "profile") @prefix = prefix @dir = dir end - def run(&block) - profiler_enabled? ? run!(&block) : block.call + def run(&) + profiler_enabled? ? run!(&) : yield end - def run!(&block) + def run! retval = nil @profile = RubyProf.profile allow_exceptions: true do @bench = Benchmark.measure do - retval = block.call + retval = yield end end retval ensure print_reports