Sha256: a2645a959ebb9233d329bc8b4aa4d4ca19bc5053fb9b4d5849d2e1a7706fe1f9

Contents?: true

Size: 474 Bytes

Versions: 20

Compression:

Stored size: 474 Bytes

Contents

module Lrama
  class Report
    module Duration
      def self.enable
        @_report_duration_enabled = true
      end

      def self.enabled?
        !!@_report_duration_enabled
      end

      def report_duration(method_name)
        time1 = Time.now.to_f
        result = yield
        time2 = Time.now.to_f

        if Duration.enabled?
          puts sprintf("%s %10.5f s", method_name, time2 - time1)
        end

        return result
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
lrama-0.6.9 lib/lrama/report/duration.rb
lrama-0.6.8 lib/lrama/report/duration.rb
lrama-0.6.7 lib/lrama/report/duration.rb
lrama-0.6.6 lib/lrama/report/duration.rb
lrama-0.6.5 lib/lrama/report/duration.rb
lrama-0.6.4 lib/lrama/report/duration.rb
lrama-0.6.3 lib/lrama/report/duration.rb
lrama-0.6.2 lib/lrama/report/duration.rb
lrama-0.6.1 lib/lrama/report/duration.rb
lrama-0.6.0 lib/lrama/report/duration.rb
lrama-0.5.12 lib/lrama/report/duration.rb
lrama-0.5.11 lib/lrama/report/duration.rb
lrama-0.5.10 lib/lrama/report/duration.rb
lrama-0.5.9 lib/lrama/report/duration.rb
lrama-0.5.8 lib/lrama/report/duration.rb
lrama-0.5.7 lib/lrama/report/duration.rb
lrama-0.5.6 lib/lrama/report/duration.rb
lrama-0.5.5 lib/lrama/report/duration.rb
lrama-0.5.4 lib/lrama/report/duration.rb
lrama-0.5.3 lib/lrama/report/duration.rb