Sha256: 3fc47c2951cc8bbf1ad71e44443e991ea587811b4259b7a5f4b39c789787127f

Contents?: true

Size: 773 Bytes

Versions: 4

Compression:

Stored size: 773 Bytes

Contents

module Timeasure
  module Profiling
    class ReportedMethodsHandler
      def initialize
        @reported_methods = {}
      end

      def report(measurement)
        initialize_path_for(measurement) if path_uninitialized_for(measurement)

        @reported_methods[measurement.full_path].increment_runtime_sum(measurement.runtime_in_milliseconds)
        @reported_methods[measurement.full_path].increment_call_count
      end

      def export
        @reported_methods.values
      end

      private

      def path_uninitialized_for(measurement)
        @reported_methods[measurement.full_path].nil?
      end

      def initialize_path_for(measurement)
        @reported_methods[measurement.full_path] = ReportedMethod.new(measurement)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
timeasure-0.2.1 lib/timeasure/profiling/reported_methods_handler.rb
timeasure-0.2.0 lib/timeasure/profiling/reported_methods_handler.rb
timeasure-0.1.1 lib/timeasure/profiling/reported_methods_handler.rb
timeasure-0.1.0 lib/timeasure/profiling/reported_methods_handler.rb