{"action":"created","issue":{"url":"https://api.github.com/repos/ariya/phantomjs/issues/13093","labels_url":"https://api.github.com/repos/ariya/phantomjs/issues/13093/labels{/name}","comments_url":"https://api.github.com/repos/ariya/phantomjs/issues/13093/comments","events_url":"https://api.github.com/repos/ariya/phantomjs/issues/13093/events","html_url":"https://github.com/ariya/phantomjs/issues/13093","id":63008719,"number":13093,"title":"Performance Timing Interface Returning unexpected values","user":{"login":"benhastings","id":3485854,"avatar_url":"https://avatars.githubusercontent.com/u/3485854?v=3","gravatar_id":"","url":"https://api.github.com/users/benhastings","html_url":"https://github.com/benhastings","followers_url":"https://api.github.com/users/benhastings/followers","following_url":"https://api.github.com/users/benhastings/following{/other_user}","gists_url":"https://api.github.com/users/benhastings/gists{/gist_id}","starred_url":"https://api.github.com/users/benhastings/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benhastings/subscriptions","organizations_url":"https://api.github.com/users/benhastings/orgs","repos_url":"https://api.github.com/users/benhastings/repos","events_url":"https://api.github.com/users/benhastings/events{/privacy}","received_events_url":"https://api.github.com/users/benhastings/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-03-19T14:54:50Z","updated_at":"2015-12-17T18:37:17Z","closed_at":null,"body":"My elation at the advent of the W3C performance timing interface being included in phantomJS was short-lived.  I fired up a simple test to evaluate some timings and was greeted with partial failure.\r\n\r\nWhat I see is all of the timing events up to responseStart being equal to the navigationStart (with the exception of redirect & SSL, I didn't take time to find a page with those events).\r\n\r\nIt seems like the actual request is being initiated before the timing object is created (that is _purely_ speculation).\r\n\r\nI'm attaching a simple script to illustrate the offending behavior.  The test URL was chosen as a control on the other side of the world (I'm in Ohio) that would ensure network latency.\r\n\r\nI'm including both the output I get from my phantomJS script and the console in Chrome when I visit the same site.\r\n\r\nChrome Output\r\n```\r\nTTFB:1793 startRender:3278\r\nVM179:18 0\t\tsecureConnectionStart\r\nVM179:18 0\t\tunloadEventStart\r\nVM179:18 0\t\tunloadEventEnd\r\nVM179:18 0\t\tredirectStart\r\nVM179:18 0\t\tredirectEnd\r\nVM179:18 1426776452218\t\tnavigationStart\r\nVM179:18 1426776452618\t\tfetchStart\r\nVM179:18 1426776452622\t\tdomainLookupStart\r\nVM179:18 1426776452624\t\tdomainLookupEnd\r\nVM179:18 1426776452624\t\tconnectStart\r\nVM179:18 1426776452625\t\trequestStart\r\nVM179:18 1426776452625\t\tconnectEnd\r\nVM179:18 1426776454011\t\tresponseStart\r\nVM179:18 1426776454013\t\tresponseEnd\r\nVM179:18 1426776454013\t\tdomLoading\r\nVM179:18 1426776455408\t\tdomInteractive\r\nVM179:18 1426776455408\t\tdomContentLoadedEventStart\r\nVM179:18 1426776455496\t\tdomContentLoadedEventEnd\r\nVM179:18 1426776457505\t\tdomComplete\r\nVM179:18 1426776457509\t\tloadEventStart\r\nVM179:18 1426776457509\t\tloadEventEnd\r\n```\r\n\r\n\r\nPhantomJS Output\r\n```\r\nStatus: success\r\n1426776521252\r\nTTFB:0 startRender:174\r\n0\t\tredirectEnd\r\n0\t\tredirectStart\r\n0\t\tsecureConnectionStart\r\n0\t\tunloadEventEnd\r\n0\t\tunloadEventStart\r\n1426776521253\t\tconnectEnd\r\n1426776521253\t\tconnectStart\r\n1426776521253\t\tdomainLookupEnd\r\n1426776521253\t\tdomainLookupStart\r\n1426776521253\t\tfetchStart\r\n1426776521253\t\tnavigationStart\r\n1426776521253\t\trequestStart\r\n1426776521253\t\tresponseStart\r\n1426776521404\t\tdomLoading\r\n1426776521426\t\tresponseEnd\r\n1426776521427\t\tdomContentLoadedEventEnd\r\n1426776521427\t\tdomContentLoadedEventStart\r\n1426776521427\t\tdomInteractive\r\n1426776521637\t\tdomComplete\r\n1426776521637\t\tloadEventStart\r\n1426776521638\t\tloadEventEnd\r\n```\r\n\r\nScript to recreate: wptDefect.js\r\n```javascript\r\n\r\nvar testURL='http://www.vilnius-tourism.lt/en/tourism';\r\n\r\nvar page = require('webpage').create();\r\nvar st = Date.now();\r\npage.open(testURL, function(status) {\r\n  console.log(\"Status: \" + status);\r\n  if(status === \"success\") {\r\n    console.log(st);\r\n    setTimeout(function(){\r\n      // To unequivocally ensure that the page has finished.\r\n      page.render('example.png');\r\n      getMetrics(page);\r\n      phantom.exit();\r\n    },2000);\r\n  }\r\n});\r\n\r\nfunction getMetrics(page) {\r\n\tvar wpt=page.evaluate(function(){\r\n\t\treturn window.performance.timing;\r\n\t});\r\n\r\n\tvar ns=wpt.navigationStart;\r\n\tvar ttfb=wpt.responseStart-ns;\r\n\tvar sr=wpt.domContentLoadedEventEnd-ns;\r\n\tconsole.log('TTFB:'+ttfb+' startRender:'+sr);\r\n        \r\n      var metrics=[];\r\n\r\n      for(var i=0;i<Object.keys(wpt).length;i++){\r\n        val={};\r\n        val.key=Object.keys(wpt)[i];\r\n        val.value=wpt[val.key];\r\n        metrics.push(val);\r\n      }\r\n\r\n  metrics.sort(function(a,b){\r\n    return a.value-b.value;\r\n  });\r\n  metrics.forEach(function(d){console.log(d.value+'\\t\\t'+d.key);});\r\n}\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/ariya/phantomjs/issues/comments/165541985","html_url":"https://github.com/ariya/phantomjs/issues/13093#issuecomment-165541985","issue_url":"https://api.github.com/repos/ariya/phantomjs/issues/13093","id":165541985,"user":{"login":"benhastings","id":3485854,"avatar_url":"https://avatars.githubusercontent.com/u/3485854?v=3","gravatar_id":"","url":"https://api.github.com/users/benhastings","html_url":"https://github.com/benhastings","followers_url":"https://api.github.com/users/benhastings/followers","following_url":"https://api.github.com/users/benhastings/following{/other_user}","gists_url":"https://api.github.com/users/benhastings/gists{/gist_id}","starred_url":"https://api.github.com/users/benhastings/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benhastings/subscriptions","organizations_url":"https://api.github.com/users/benhastings/orgs","repos_url":"https://api.github.com/users/benhastings/repos","events_url":"https://api.github.com/users/benhastings/events{/privacy}","received_events_url":"https://api.github.com/users/benhastings/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T18:37:17Z","updated_at":"2015-12-17T18:37:17Z","body":"Yes @fromIRIS - the defect was evident when running from a shell.\r\n\r\nI was just given a windows machine a few weeks ago and it seems to be working (as mentioned above).  I'm trying to fire up another ubuntu image and run it there.  My hope was to use remote hosts for periodic performance monitoring."}}