在watir-webdriver-performance gem中,response_time,:time_to_first_byte和:time_to_last_byte有什么区别?

Mel*_*ssa 2 performance-testing watir-webdriver

我用谷歌搜索,搜索了SO,并阅读主页上推荐的导航时间页面,但无法自行解决.

是什么区别:response_time,:time_to_first_byte:time_to_last_byte

从我的理解,以及在导航计时文档,似乎:response_time应该是的总和:time_to_first_byte,和:time_to_last_byte,但是在执行我的测试中,我发现事实并非如此.

    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
Run Code Online (Sandbox Code Playgroud)

我看到的典型输出是:

    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.
Run Code Online (Sandbox Code Playgroud)

谢谢.

小智 5

第一个字节的时间(TTFB)是服务器返回响应中信息的第一个字节所花费的时间.所以此宝石中的TTFB相当于:

response_start - domain_lookup_start if domain_lookup_start > 0

并将包括DNS,连接和请求开销.

此gem中的最后一个字节的时间(TTLB)相当于:

response_end - domain_lookup_start

所以应该包括DNS,连接,请求和响应开销.

所以在你的例子中,在TTFB和TTLB之间传输内容只需要1ms.摘要中的响应时间是散列中所有测量的最早和最晚时间戳之间的差值.所以实际上在navigation_start和load_end之间的一切.

这包括规范中提供的所有DNS,TCP,连接,请求,响应和浏览器处理/加载时序.

在您的代码中,如果您只是转储哈希

$browser.performance.summary

您应该能够看到所有相关指标.