Class: SpeedGun::Browser::Timing
- Inherits:
-
Hash
- Object
- Hash
- SpeedGun::Browser::Timing
- Defined in:
- lib/speed_gun/browser/timing.rb
Defined Under Namespace
Classes: Timing
Constant Summary collapse
- ATTRIBUTES =
rubocop:disable SymbolName
[ :navigationStart, :unloadEventStart, :unloadEventEnd, :redirectStart, :redirectEnd, :fetchStart, :domainLookupStart, :domainLookupEnd, :connectStart, :connectEnd, :secureConnectionStart, :requestStart, :responseStart, :responseEnd, :domLoading, :domInteractive, :domContentLoadedEventStart, :domContentLoadedEventEnd, :domComplete, :loadEventStart, :loadEventEnd, ]
Instance Method Summary collapse
-
#initialize(hash) ⇒ Timing
constructor
A new instance of Timing.
- #load_time ⇒ Object
-
#timings ⇒ Object
rubocop:disable MethodLength.
Constructor Details
#initialize(hash) ⇒ Timing
Returns a new instance of Timing.
39 40 41 42 43 |
# File 'lib/speed_gun/browser/timing.rb', line 39 def initialize(hash) hash.each_pair do |key, val| self[key.to_s.to_sym] = val.to_i end end |
Instance Method Details
#load_time ⇒ Object
49 50 51 |
# File 'lib/speed_gun/browser/timing.rb', line 49 def load_time loadEventEnd - end |
#timings ⇒ Object
rubocop:disable MethodLength
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/speed_gun/browser/timing.rb', line 54 def timings @timings ||= [ ( if redirectStart > 0 Timing.new('Redirect', , redirectStart, redirectEnd) else nil end ), Timing.new('Fetch all', , fetchStart, responseEnd), Timing.new( 'DNS Lookup', , domainLookupStart, domainLookupEnd ), Timing.new( 'TCP Connecting', , connectStart, connectEnd ), ( if secureConnectionStart > 0 Timing.new('SSL', , secureConnectionStart, connectEnd) else nil end ), Timing.new('Request', , requestStart, responseStart), Timing.new('Response', , responseStart, responseEnd), Timing.new('Unload', , unloadEventStart, unloadEventEnd), Timing.new('DOM Load', , domLoading, domInteractive), Timing.new( 'DOMContentLoaded Event', , domContentLoadedEventStart, domContentLoadedEventEnd ), Timing.new( 'Sub resources loading', , domInteractive, domComplete ), Timing.new('Load Event', , loadEventStart, loadEventEnd), ].reject { |timing| timing.nil? } end |