Sha256: e3998ec312edbd1262453c79aac9fea0af59f717e4d7eab82b632d0f6ca504b5
Contents?: true
Size: 984 Bytes
Versions: 7
Compression:
Stored size: 984 Bytes
Contents
require 'uri' module Fozzie class Mill DELIMETER = ';' METRICS = %w{ttfb load} attr_reader :str, :args def initialize(str = "") @str = str escaped_split = str.split(DELIMETER).map!{|x| URI.unescape(x) } @args = Hash[*escaped_split] end def self.register(str = "") new(str).register end def register return self unless self.has_href? METRICS.each do |k| next unless self.respond_to?(k.to_sym) S.timing((namespace << ['page', k]).flatten, self.send(k.to_sym)) end self end def load @load ||= @args['domComplete'].to_i - @args['fetchStart'].to_i end def ttfb @ttfb ||= @args['responseStart'].to_i - @args['fetchStart'].to_i end def has_href? !@args['href'].nil? end def namespace @uri ||= URI(@args['href']) @path ||= @uri.path.strip.split('/').reject(&:empty?) @path.dup end end end
Version data entries
7 entries across 7 versions & 1 rubygems