2

I've googled, searched through SO, and read through the Navigation Timing page recommended on the host page, but was unable to resolve on my own.

What is the difference between :response_time, :time_to_first_byte, and :time_to_last_byte?

From my understanding, as well as the Navigation Timing documentation, it seems :response_time should be the sum of :time_to_first_byte, and :time_to_last_byte, however upon executing my tests I've found it isn't.

    require 'watir-webdriver-performance'

    $response = $browser.performance.summary[:response_time]
    $first_byte = $browser.performance.summary[:time_to_first_byte]
    $last_byte = $browser.performance.summary[:time_to_last_byte]

    def performance_check
        puts ("#{$browser.url}: Response time: #{$response}ms.")

        puts ("#{$browser.url}: Time to first byte: #{$first_byte}ms.")

        puts ("#{$browser.url}: Time to last byte: #{$last_byte}ms.")
    end

    def test_site_01
      $browser.goto("http://www.google.com/")
      performance_check 
    end

The typical output I'm seeing is:

    http://www.google.com: Response time: 1558ms.
    http://www.google.com: Time to first byte: 384ms.
    http://www.google.com: Time to last byte: 385ms.

Thank you.

Marc
  • 16,170
  • 20
  • 76
  • 119
Mellissa
  • 138
  • 5

1 Answers1

5

Time to First Byte (TTFB) is the time it takes the server to return the first byte of information in a response. So TTFB in this gem is equivalent to:

response_start - domain_lookup_start if domain_lookup_start > 0

and would include DNS, connection and request overheads.

Time to Last Byte (TTLB) in this gem is equivalent to:

response_end - domain_lookup_start

so should include DNS, connection, request & response overheads.

So in your example, it only took 1ms effectively to transfer content between TTFB and TTLB. The response time in the summary is the delta between the earliest and latest timestamp for all measurements in the hash. So in effect everything between navigation_start and load_end.

This includes all DNS, TCP, connection, request, response and browser processing / on load timings available in the spec.

In your code if you just dump the hash

$browser.performance.summary

you should be able to see all the relevant metrics.

Tim Koopmans
  • 788
  • 4
  • 9