Sha256: 023203396dfae4d0cd3f9ec98d861eda4bc51788d4fbf76a90b59160876f7216

Contents?: true

Size: 622 Bytes

Versions: 1

Compression:

Stored size: 622 Bytes

Contents

module Koine
  class Profiler
    class EntryGroup
      InvalidEntryError = Class.new(StandardError)

      attr_reader :name, :entries

      def initialize(name)
        @name = name.to_s
        @entries = []
      end

      def append(entry)
        raise InvalidEntryError.new(entry.name) unless entry.name == name

        entries << entry
      end

      def ==(other)
        entries == other.entries
      end

      def <=>(other)
        elapsed_time <=> other.elapsed_time
      end

      def elapsed_time
        entries.inject(0) { |total, entry| entry.elapsed_time + total }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
koine-profiler-0.1.0 lib/koine/profiler/entry_group.rb