Sha256: 7700623fd1c0ec3986d271ffe0562c4c77d832c0bae4527c6bcefe01f00fdf03

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

module Hippoload
  class HippoParser

    # Inspired by https://github.com/wjessop/httperf-output-parser/blob/master/lib/httperf-output-parser.rb

    DATATYPES = %w(
                total_conenctions
                duration
                connections_per_second
                min_ms_per_connection
                avg_ms_per_connection
                max_ms_per_connection
                median_ms_per_connection
                stddev_ms_per_connection
                request_rate_per_second
                min_replies_per_second
                avg_replies_per_second
                max_replies_per_second
                stddev_replies_per_second
                samples
                client_timeout_errors
                connections_reset_errors
               )

    def parse(httperf_raw_output)
      return nil if httperf_raw_output.nil?

      formatted_output = formatted_output(httperf_raw_output)
      matched_data = formatted_output.match(/Total: connections (\d+).+test-duration ([\d.]+).+Connection rate: ([\d.]+).+Connection time \[ms\]: min ([\d.]+).+avg ([\d.]+).+max ([\d.]+).+median ([\d.]+).+stddev ([\d.]+).+Request rate: ([\d.]+).+min ([\d.]+).+avg ([\d.]+).+max ([\d.]+).+stddev ([\d.]+).+(\d+) samples.+client-timo (\d+).+connreset (\d+)/)

      parsed_data = {}
      DATATYPES.size.times do |i|
        parsed_data[DATATYPES[i].to_sym] = matched_data[i+1]
      end

      parsed_data
    end

    private

    def formatted_output(httperf_raw_output)
      httperf_raw_output.inspect.split('\n').join(' ')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hippoload-0.0.2 lib/hippoload/hippo_parser.rb