From 0077b3b32f23ed17cfeddf48cf88ed0e511347b2 Mon Sep 17 00:00:00 2001 From: cws Date: Tue, 4 Jun 2013 15:27:22 +0200 Subject: [PATCH 1/5] Commands setDOMElement (for Firefox and Chrome) and setEventName repaired Adapted compile.cmd script for compiling chrome extension (python.exe has to be included to path to use) Fixed Bug: setDOMElement for Chrome didn't reset expected dom elements at a new page Conflicts: agent/browser/chrome/compile.cmd agent/browser/chrome/extension/release/wpt/allTests.js agent/browser/chrome/extension/release/wpt/background.js agent/browser/chrome/extension/wpt/background.js agent/browser/chrome/extension/wpt/commands.js agent/wptdriver/wpt_test.cc agent/wptdriver/wpt_test.h agent/wpthook/request.cc agent/wpthook/request.h agent/wpthook/results.cc --- agent/browser/chrome/compile.cmd | 3 ++- .../chrome/extension/release/wpt/allTests.js | 4 +-- .../extension/release/wpt/background.js | 17 ++++++++++-- .../chrome/extension/wpt/background.js | 13 ++++++++++ .../browser/chrome/extension/wpt/commands.js | 4 +-- .../extension/chrome/content/overlay.js | 8 ++++-- agent/wptdriver/wpt_test.cc | 26 ++++++++++++++++++- agent/wptdriver/wpt_test.h | 5 ++++ agent/wpthook/request.cc | 7 +++++ agent/wpthook/request.h | 4 +++ agent/wpthook/results.cc | 5 ++-- 11 files changed, 84 insertions(+), 12 deletions(-) diff --git a/agent/browser/chrome/compile.cmd b/agent/browser/chrome/compile.cmd index 2f8ea4a7b0..6166e40c51 100644 --- a/agent/browser/chrome/compile.cmd +++ b/agent/browser/chrome/compile.cmd @@ -3,7 +3,7 @@ rmdir /S /Q "%~dp0extension/release" mkdir "%~dp0extension/release" mkdir "%~dp0extension/release/wpt" set CLOSURE_COMPILER_JAR="%~dp0/compiler.jar" -set COMPILE_JS=C:\Python_26\files\python.exe "%~dp0extension/third_party/closure-library/closure/bin/build/closurebuilder.py" ^ +set COMPILE_JS=python.exe "%~dp0extension/third_party/closure-library/closure/bin/build/closurebuilder.py" ^ --root="%~dp0extension/third_party/closure-library/" ^ --root="%~dp0extension/wpt" ^ --compiler_jar=%CLOSURE_COMPILER_JAR% ^ @@ -25,4 +25,5 @@ copy "%~dp0extension\manifest.json" "%~dp0extension\release\manifest.json" copy "%~dp0extension\wpt\*.html" "%~dp0extension\release\wpt\" copy "%~dp0extension\wpt\*.jpg" "%~dp0extension\release\wpt\" copy "%~dp0extension\wpt\*.css" "%~dp0extension\release\wpt\" +xcopy /e /v /y "%~dp0extension\release\*" "%~dp0extension\..\..\..\..\Debug\extension\" pause diff --git a/agent/browser/chrome/extension/release/wpt/allTests.js b/agent/browser/chrome/extension/release/wpt/allTests.js index 74979b145c..c66588b0bc 100644 --- a/agent/browser/chrome/extension/release/wpt/allTests.js +++ b/agent/browser/chrome/extension/release/wpt/allTests.js @@ -18179,9 +18179,9 @@ wpt.commands.CommandRunner.prototype.doSetDOMElements = function() { if (goog.isNull(g_tabid)) throw ('It should not be posible to run the doSetDOMElements() method ' + 'before we find the id of the tab in which pages are loaded.'); - + chrome.tabs.sendRequest( - g_tabid, + g_tabid, {'message': 'setDOMElements', name_values: wpt.commands.g_domElements}, function(response) {}); wpt.LOG.info('doSetDOMElements for : ' + wpt.commands.g_domElements); diff --git a/agent/browser/chrome/extension/release/wpt/background.js b/agent/browser/chrome/extension/release/wpt/background.js index f5d921b949..8fd6e89988 100644 --- a/agent/browser/chrome/extension/release/wpt/background.js +++ b/agent/browser/chrome/extension/release/wpt/background.js @@ -13830,9 +13830,9 @@ wpt.commands.CommandRunner.prototype.doSetDOMElements = function() { if (goog.isNull(g_tabid)) throw ('It should not be posible to run the doSetDOMElements() method ' + 'before we find the id of the tab in which pages are loaded.'); - + chrome.tabs.sendRequest( - g_tabid, + g_tabid, {'message': 'setDOMElements', name_values: wpt.commands.g_domElements}, function(response) {}); wpt.LOG.info('doSetDOMElements for : ' + wpt.commands.g_domElements); @@ -14718,6 +14718,10 @@ var wptTaskCallback = function() { window.setTimeout(wptGetTask, TASK_INTERVAL_SHORT); } +// Boolean if a navigation command occured +// (needed to reset expected dom elements for setDOMElement command) +var g_navigationCmd = false; + // execute a single task/script command function wptExecuteTask(task) { if (task.action.length) { @@ -14735,10 +14739,12 @@ function wptExecuteTask(task) { case 'navigate': g_processing_task = true; g_commandRunner.doNavigate(task.target, wptTaskCallback); + g_navigationCmd = true; break; case 'exec': g_processing_task = true; g_commandRunner.doExec(task.target, wptTaskCallback); + g_navigationCmd = true; break; case 'setcookie': g_commandRunner.doSetCookie(task.target, task.value); @@ -14747,6 +14753,11 @@ function wptExecuteTask(task) { g_commandRunner.doBlock(task.target); break; case 'setdomelement': + // Reset dom elements if navigation command occured before + if(g_navigationCmd){ + wpt.commands.g_domElements = []; + g_navigationCmd = false; + } // Sending request to set the DOM element has to happen only at the // navigate event after the content script is loaded. So, this just // sets the global variable. @@ -14755,6 +14766,7 @@ function wptExecuteTask(task) { case 'click': g_processing_task = true; g_commandRunner.doClick(task.target, wptTaskCallback); + g_navigationCmd = true; break; case 'setinnerhtml': g_processing_task = true; @@ -14771,6 +14783,7 @@ function wptExecuteTask(task) { case 'submitform': g_processing_task = true; g_commandRunner.doSubmitForm(task.target, wptTaskCallback); + g_navigationCmd = true; break; case 'clearcache': g_processing_task = true; diff --git a/agent/browser/chrome/extension/wpt/background.js b/agent/browser/chrome/extension/wpt/background.js index 61f1330783..ad4aa79588 100644 --- a/agent/browser/chrome/extension/wpt/background.js +++ b/agent/browser/chrome/extension/wpt/background.js @@ -405,6 +405,10 @@ var wptTaskCallback = function() { window.setTimeout(wptGetTask, TASK_INTERVAL_SHORT); } +// Boolean if a navigation command occured +// (needed to reset expected dom elements for setDOMElement command) +var g_navigationCmd = false; + // execute a single task/script command function wptExecuteTask(task) { if (task.action.length) { @@ -422,10 +426,12 @@ function wptExecuteTask(task) { case 'navigate': g_processing_task = true; g_commandRunner.doNavigate(task.target, wptTaskCallback); + g_navigationCmd = true; break; case 'exec': g_processing_task = true; g_commandRunner.doExec(task.target, wptTaskCallback); + g_navigationCmd = true; break; case 'setcookie': g_commandRunner.doSetCookie(task.target, task.value); @@ -434,6 +440,11 @@ function wptExecuteTask(task) { g_commandRunner.doBlock(task.target); break; case 'setdomelement': + // Reset dom elements if navigation command occured before + if(g_navigationCmd){ + wpt.commands.g_domElements = []; + g_navigationCmd = false; + } // Sending request to set the DOM element has to happen only at the // navigate event after the content script is loaded. So, this just // sets the global variable. @@ -442,6 +453,7 @@ function wptExecuteTask(task) { case 'click': g_processing_task = true; g_commandRunner.doClick(task.target, wptTaskCallback); + g_navigationCmd = true; break; case 'setinnerhtml': g_processing_task = true; @@ -458,6 +470,7 @@ function wptExecuteTask(task) { case 'submitform': g_processing_task = true; g_commandRunner.doSubmitForm(task.target, wptTaskCallback); + g_navigationCmd = true; break; case 'clearcache': g_processing_task = true; diff --git a/agent/browser/chrome/extension/wpt/commands.js b/agent/browser/chrome/extension/wpt/commands.js index 89b2f8fd3d..7cbb9203eb 100644 --- a/agent/browser/chrome/extension/wpt/commands.js +++ b/agent/browser/chrome/extension/wpt/commands.js @@ -268,9 +268,9 @@ wpt.commands.CommandRunner.prototype.doSetDOMElements = function() { if (goog.isNull(g_tabid)) throw ('It should not be posible to run the doSetDOMElements() method ' + 'before we find the id of the tab in which pages are loaded.'); - + chrome.tabs.sendRequest( - g_tabid, + g_tabid, {'message': 'setDOMElements', name_values: wpt.commands.g_domElements}, function(response) {}); wpt.LOG.info('doSetDOMElements for : ' + wpt.commands.g_domElements); diff --git a/agent/browser/firefox/extension/chrome/content/overlay.js b/agent/browser/firefox/extension/chrome/content/overlay.js index 74e004da51..8b6a05f377 100644 --- a/agent/browser/firefox/extension/chrome/content/overlay.js +++ b/agent/browser/firefox/extension/chrome/content/overlay.js @@ -511,8 +511,8 @@ wpt.moz.main.setDomElement = function(target) { wpt.moz.main.pollForDomElements = function() { var missingDomElements = []; - for (var i = 0, ie = wpt.moz.main.domElementsToWaitOn_.length; i < ie; i++) { - var target = wpt.moz.main.domElementsToWaitOn_[i]; + for (var i = 0; i < wpt.moz.main.domElementsToWaitOn_.length; i++) { + var target = wpt.moz.main.domElementsToWaitOn_[i]; var targetInPage = SendCommandToContentScript_({ 'command': 'isTargetInDom', 'target': target @@ -522,7 +522,11 @@ wpt.moz.main.pollForDomElements = function() { var domElementParams = { 'name_value': target }; + wpt.moz.main.sendEventToDriver_('dom_element', domElementParams); + var index = wpt.moz.main.domElementsToWaitOn_.indexOf(target) + wpt.moz.main.domElementsToWaitOn_.splice(index, 1);; + i--; } else { // If we did not find |target|, save it for the next poll. missingDomElements.push(target); diff --git a/agent/wptdriver/wpt_test.cc b/agent/wptdriver/wpt_test.cc index 041c900465..a1dc6e6a50 100644 --- a/agent/wptdriver/wpt_test.cc +++ b/agent/wptdriver/wpt_test.cc @@ -656,6 +656,11 @@ bool WptTest::ProcessCommand(ScriptCommand& command, bool &consumed) { _block_requests.AddTail(command.target); continue_processing = false; consumed = false; + } else if (cmd == _T("seteventname")) { + event_name = command.target; + convertForHTML(event_name); + WptTrace(loglevel::kFrequentEvent, + _T("[wpthook] - WptTest - received SetEventName-command: "+command.target)); } else if (cmd == _T("setdomelement")) { if (command.target.Trim().GetLength()) { _dom_element_check = true; @@ -681,7 +686,7 @@ bool WptTest::ProcessCommand(ScriptCommand& command, bool &consumed) { continue_processing = false; consumed = false; } - + return continue_processing; } @@ -1007,3 +1012,22 @@ void WptTest::Unlock() { bool WptTest::IsLocked() { return lock_count_ != 0; } + +void WptTest::convertForHTML(CString& text){ + text.Replace(_T("ä"), _T("ae")); + text.Replace(_T("ö"), _T("oe")); + text.Replace(_T("ü"), _T("ue")); + text.Replace(_T("Ä"), _T("Ae")); + text.Replace(_T("Ö"), _T("Oe")); + text.Replace(_T("Ü"), _T("Ue")); + text.Replace(_T("ß"), _T("ss")); + + // Can't be used since WPT-Server-Code isn't capable to handle it + // text.Replace(_T("ä"), _T("ä")); + // text.Replace(_T("ö"), _T("ö")); + // text.Replace(_T("ü"), _T("ü")); + // text.Replace(_T("Ä"), _T("Ä")); + // text.Replace(_T("Ö"), _T("Ö")); + // text.Replace(_T("Ü"), _T("Ü")); + // text.Replace(_T("ß"), _T("ß")); +} \ No newline at end of file diff --git a/agent/wptdriver/wpt_test.h b/agent/wptdriver/wpt_test.h index 04310e2e62..288ca24a08 100644 --- a/agent/wptdriver/wpt_test.h +++ b/agent/wptdriver/wpt_test.h @@ -209,6 +209,8 @@ class WptTest { // Whether we need to wait for DOM element. bool _dom_element_check; int _no_run; // conditional block support - if/else/endif + // for seteventname command + CString event_name; // system information bool has_gpu_; @@ -241,4 +243,7 @@ class WptTest { CAtlList _override_hosts; CAtlMap _tcp_port_override; + +private: + void convertForHTML(CString& text); }; diff --git a/agent/wpthook/request.cc b/agent/wpthook/request.cc index b94fd9c244..aefde7b602 100644 --- a/agent/wpthook/request.cc +++ b/agent/wpthook/request.cc @@ -363,6 +363,13 @@ Request::~Request(void) { DeleteCriticalSection(&cs); } +CStringA Request::GetEventName(void){ + return CT2A(event_name); +} + +void Request::SetEventName(CString eventName){ + event_name = eventName; +} /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ void Request::DataIn(DataChunk& chunk) { diff --git a/agent/wpthook/request.h b/agent/wpthook/request.h index 7f408da615..733f40b4f9 100644 --- a/agent/wpthook/request.h +++ b/agent/wpthook/request.h @@ -241,6 +241,8 @@ class Request { ULONG GetPeerAddress(); CString GetUrl(); + CStringA GetEventName(); + void SetEventName(CString eventName); bool _processed; bool _reported; DWORD _socket_id; @@ -248,6 +250,8 @@ class Request { int _local_port; bool _is_ssl; bool _is_spdy; + + CString event_name; CString initiator_; CString initiator_line_; CString initiator_column_; diff --git a/agent/wpthook/results.cc b/agent/wpthook/results.cc index 1d3a9a08fb..02afa21385 100644 --- a/agent/wpthook/results.cc +++ b/agent/wpthook/results.cc @@ -408,7 +408,7 @@ void Results::SavePageData(OptimizationChecks& checks){ _test_state._start_time.wMinute, _test_state._start_time.wSecond); result += buff; // Event Name - result += "\t"; + result += (CT2A(checks._test.event_name + "\t")); // URL result += CStringA((LPCSTR)CT2A(_test._navigated_url)) + "\t"; // Load Time (ms) @@ -867,6 +867,7 @@ void Results::SaveRequests(OptimizationChecks& checks) { request->_reported = true; if (request->_processed) { i++; + request->SetEventName(checks._test.event_name); SaveRequest(file, headers_file, request, i); if (!request->_custom_rules_matches.IsEmpty() && custom_rules_file != INVALID_HANDLE_VALUE) { @@ -931,7 +932,7 @@ void Results::SaveRequest(HANDLE file, HANDLE headers, Request * request, _test_state._start_time.wMinute, _test_state._start_time.wSecond); result += buff; // Event Name - result += "\t"; + result += request->GetEventName()+"\t"; // IP Address struct sockaddr_in addr; addr.sin_addr.S_un.S_addr = request->_peer_address; From f91fc6cc80503d70681d9b96f624f879bf660ad0 Mon Sep 17 00:00:00 2001 From: cws Date: Tue, 4 Jun 2013 16:22:43 +0200 Subject: [PATCH 2/5] Agent changes for measuring multiple steps (renamed result files) Conflicts: agent/wpthook/results.cc agent/wpthook/results.h Conflicts: agent/wpthook/results.cc --- agent/wpthook/results.cc | 29 ++++++++++++++++++++--------- agent/wpthook/results.h | 1 + 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/agent/wpthook/results.cc b/agent/wpthook/results.cc index 02afa21385..b175a4f57b 100644 --- a/agent/wpthook/results.cc +++ b/agent/wpthook/results.cc @@ -74,7 +74,8 @@ Results::Results(TestState& test_state, WptTest& test, Requests& requests, , _screen_capture(screen_capture) , _saved(false) , _dev_tools(dev_tools) - , _trace(trace) { + , _trace(trace) + , currentPage(1) { _file_base = shared_results_file_base; _visually_complete.QuadPart = 0; WptTrace(loglevel::kFunction, _T("[wpthook] - Results base file: %s"), @@ -213,15 +214,23 @@ void Results::SaveStatusMessages(void) { void Results::SaveImages(void) { // save the event-based images CxImage image; - if (_screen_capture.GetImage(CapturedImage::START_RENDER, image)) - SaveImage(image, _file_base + IMAGE_START_RENDER, _test._image_quality); - if (_screen_capture.GetImage(CapturedImage::DOCUMENT_COMPLETE, image)) - SaveImage(image, _file_base + IMAGE_DOC_COMPLETE, _test._image_quality); + CString page("_"); + page.AppendChar(char(currentPage + '0')); + if (_screen_capture.GetImage(CapturedImage::START_RENDER, image)) { + SaveImage(image, _file_base + page + IMAGE_START_RENDER, + _test._image_quality); + } + if (_screen_capture.GetImage(CapturedImage::DOCUMENT_COMPLETE, image)) { + SaveImage(image, _file_base + page + IMAGE_DOC_COMPLETE, + _test._image_quality); + } if (_screen_capture.GetImage(CapturedImage::FULLY_LOADED, image)) { if (_test._png_screen_shot) - image.Save(_file_base + IMAGE_FULLY_LOADED_PNG, CXIMAGE_FORMAT_PNG); - SaveImage(image, _file_base + IMAGE_FULLY_LOADED, _test._image_quality); + image.Save(_file_base + page + IMAGE_FULLY_LOADED_PNG, CXIMAGE_FORMAT_PNG); + SaveImage(image, _file_base + page + IMAGE_FULLY_LOADED, + _test._image_quality); } + currentPage++; if (_test._video) SaveVideo(); @@ -827,6 +836,8 @@ void Results::ProcessRequests(void) { /*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ void Results::SaveRequests(OptimizationChecks& checks) { + CString page("_"); + page.AppendChar(char(currentPage + '0')); HANDLE file = CreateFile(_file_base + REQUEST_DATA_FILE, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, 0); if (file != INVALID_HANDLE_VALUE) { @@ -834,7 +845,7 @@ void Results::SaveRequests(OptimizationChecks& checks) { CStringA buff; SetFilePointer( file, 0, 0, FILE_END ); - HANDLE headers_file = CreateFile(_file_base + REQUEST_HEADERS_DATA_FILE, + HANDLE headers_file = CreateFile(_file_base + page + REQUEST_HEADERS_DATA_FILE, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); HANDLE custom_rules_file = INVALID_HANDLE_VALUE; @@ -1257,4 +1268,4 @@ bool Results::NativeRequestExists(Request * browser_request) { } else ret = true; return ret; -} \ No newline at end of file +} diff --git a/agent/wpthook/results.h b/agent/wpthook/results.h index 35b3a5989b..53fb0ba739 100644 --- a/agent/wpthook/results.h +++ b/agent/wpthook/results.h @@ -73,6 +73,7 @@ class Results { CStringA base_page_server_rtt_; int base_page_address_count_; bool adult_site_; + int currentPage; int count_connect_; int count_connect_doc_; From 85ec6a55c5a9faee85fcb46f2cad5119aded7ea2 Mon Sep 17 00:00:00 2001 From: cws Date: Tue, 5 Nov 2013 11:13:34 +0100 Subject: [PATCH 3/5] Added "cleanup-batch" option for browser settings in "wptdriver.ini". The batch is executed after the browser should have been closed (e.g. the script can be used to close browser if it is still running) Conflicts: agent/wptdriver/web_browser.cc agent/wptdriver/wpt_settings.cc agent/wptdriver/wpt_settings.h --- agent/wptdriver/web_browser.cc | 4 ++++ agent/wptdriver/wpt_settings.cc | 6 ++++++ agent/wptdriver/wpt_settings.h | 1 + 3 files changed, 11 insertions(+) diff --git a/agent/wptdriver/web_browser.cc b/agent/wptdriver/web_browser.cc index c7c10973e2..b8d7c468c9 100644 --- a/agent/wptdriver/web_browser.cc +++ b/agent/wptdriver/web_browser.cc @@ -319,6 +319,10 @@ bool WebBrowser::RunAndWait(bool &critical_error) { WaitForSingleObject(additional_process, 120000); CloseHandle(additional_process); } + // Execute browser cleanup batch file + if(_browser._cleanupBatch && _browser._cleanupBatch.GetLength() > 0){ + system(CT2A(_browser._cleanupBatch)); + } LeaveCriticalSection(&cs); ResetIpfw(); RemoveGlobalHook(); diff --git a/agent/wptdriver/wpt_settings.cc b/agent/wptdriver/wpt_settings.cc index ec8fca574a..214b82b403 100644 --- a/agent/wptdriver/wpt_settings.cc +++ b/agent/wptdriver/wpt_settings.cc @@ -268,6 +268,7 @@ bool BrowserSettings::Load(const TCHAR * browser, const TCHAR * iniFile, _exe.Empty(); _exe_directory.Empty(); _options.Empty(); + _cleanupBatch.Empty(); AtlTrace(_T("Loading settings for %s"), (LPCTSTR)browser); @@ -314,6 +315,11 @@ bool BrowserSettings::Load(const TCHAR * browser, const TCHAR * iniFile, ret = true; } + if (GetPrivateProfileString(browser, _T("cleanup-batch"), _T(""), buff, + _countof(buff), iniFile )) { + _cleanupBatch = buff; + } + if (GetPrivateProfileString(browser, _T("options"), _T(""), buff, _countof(buff), iniFile )) { _options = buff; diff --git a/agent/wptdriver/wpt_settings.h b/agent/wptdriver/wpt_settings.h index 43596e26ed..cd227d200c 100644 --- a/agent/wptdriver/wpt_settings.h +++ b/agent/wptdriver/wpt_settings.h @@ -66,6 +66,7 @@ class BrowserSettings { CString _exe_directory; CString _profile_directory; CString _cache_directory; + CString _cleanupBatch; // Windows/IE directories CString windows_dir_; From 36139b63f2ff7a9bf63f71969c49c7f32c06f6d2 Mon Sep 17 00:00:00 2001 From: cws Date: Wed, 6 Nov 2013 09:04:08 +0100 Subject: [PATCH 4/5] Extended server for test scripts which measure multiple steps Conflicts: www/webpagetest/breakdown.inc www/webpagetest/breakdown.php www/webpagetest/customWaterfall.php www/webpagetest/details.php www/webpagetest/domains.inc www/webpagetest/domains.php www/webpagetest/export.php www/webpagetest/object_detail.inc www/webpagetest/optimization.inc www/webpagetest/optimizationChecklist.php www/webpagetest/page_data.inc www/webpagetest/pageimages.php www/webpagetest/performance_optimization.php www/webpagetest/result.inc www/webpagetest/results.php www/webpagetest/screen_shot.php www/webpagetest/thumbnail.php www/webpagetest/utils.inc www/webpagetest/video/compare.php www/webpagetest/waterfall.css www/webpagetest/waterfall.inc www/webpagetest/waterfall.js www/webpagetest/waterfall.php www/webpagetest/waterfall_detail.inc www/webpagetest/work/workdone.php www/webpagetest/xmlResult.php --- www/.htaccess | 14 +- www/breakdown.inc | 34 +- www/breakdown.php | 132 +++-- www/customWaterfall.php | 39 +- www/details.php | 885 ++++++++++++++++++----------- www/domains.inc | 13 +- www/domains.php | 111 ++-- www/export.php | 76 +-- www/object_detail.inc | 239 ++++---- www/optimization.inc | 36 +- www/optimizationChecklist.php | 5 +- www/page_data.inc | 912 +++++++++++++++--------------- www/pageimages.php | 5 +- www/performance_optimization.php | 37 +- www/result.inc | 936 +++++++++++++++++-------------- www/results.php | 5 +- www/screen_shot.php | 75 ++- www/thumbnail.php | 40 +- www/utils.inc | 176 ++++++ www/video/compare.php | 4 +- www/waterfall.css | 8 +- www/waterfall.inc | 271 +++++---- www/waterfall.js | 291 +++++++--- www/waterfall.php | 19 +- www/waterfall_detail.inc | 153 ++--- www/work/workdone.php | 38 +- www/xmlResult.php | 365 ++++++++---- 27 files changed, 2959 insertions(+), 1960 deletions(-) create mode 100644 www/utils.inc diff --git a/www/.htaccess b/www/.htaccess index 07d68653fb..43f3292a23 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -31,7 +31,7 @@ RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/optimization/cached$ /result/$1/$2/performance_optimization/cached/ [R] RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/optimization/cached/$ /result/$1/$2/performance_optimization/cached/ [R] RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/performance_optimization/cached/$ /performance_optimization.php?test=$1&run=$2&cached=1 [qsa] - RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/screen_shot/$ /screen_shot.php?test=$1&run=$2 [qsa] + RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/screen_shot/$ /screen_shot.php?test=$1&run=$2 [qsa] RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/screen_shot/cached/$ /screen_shot.php?test=$1&run=$2&cached=1 [qsa] RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/breakdown/$ /breakdown.php?test=$1&run=$2 [qsa] RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/breakdown/cached/$ /breakdown.php?test=$1&run=$2&cached=1 [qsa] @@ -57,12 +57,19 @@ RewriteRule ^result/([a-zA-Z0-9_]+)/.*requests.csv$ /csv.php?test=$1&requests=1 #thumbnails - RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_screen_thumb.jpg$ /thumbnail.php?test=$1&run=$2&file=$2_screen.jpg - RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_Cached_screen_thumb.jpg$ /thumbnail.php?test=$1&run=$2&cached=1&file=$2_Cached_screen.jpg + RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_screen_thumb.jpg$ /thumbnail.php?test=$1&run=$2&file=$2_1_screen.jpg + RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_Cached_screen_thumb.jpg$ /thumbnail.php?test=$1&run=$2&cached=1&file=$2_Cached_1_screen.jpg + RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_([0-9]+)_screen_thumb.jpg$ /thumbnail.php?test=$1&run=$2&file=$2_$3_screen.jpg + RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_Cached_([0-9]+)_screen_thumb.jpg$ /thumbnail.php?test=$1&run=$2&cached=1&file=$2_Cached_$3_screen.jpg RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_waterfall_thumb.png$ /thumbnail.php?test=$1&run=$2&file=$2_waterfall.png RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_Cached_waterfall_thumb.png$ /thumbnail.php?test=$1&run=$2&cached=1&file=$2_Cached_waterfall.png + # Param1 = TestId, Param2 = RunNumber, Param3 = EventName, Param4 = EventNameId + RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/(.+)/waterfall_thumb.png$ /thumbnail.php?test=$1&run=$2&eventName=$3&file=$2_$4_waterfall.png + RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/(.+)/Cached_waterfall_thumb.png$ /thumbnail.php?test=$1&run=$2&cached=1&eventName=$3&file=$2_Cached_$4_waterfall.png RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_optimization_thumb.png$ /thumbnail.php?test=$1&run=$2&file=$2_optimization.png RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)_Cached_optimization_thumb.png$ /thumbnail.php?test=$1&run=$2&cached=1&file=$2_Cached_optimization.png + RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/optimization_thumb.png$ /thumbnail.php?test=$1&run=$2&eventName=$3&file=$2_$3_optimization.png + RewriteRule ^result/([a-zA-Z0-9_]+)/([0-9]+)/(.+)/Cached_optimization_thumb.png$ /thumbnail.php?test=$1&run=$2&cached=1&eventName=$3&file=$2_Cached_$3_optimization.png #old direct thumbnail paths RewriteRule ^results/old/([a-zA-Z0-9_]+)/([0-9]+)_screen_thumb.jpg$ /thumbnail.php?test=$1&run=$2&file=$2_screen.jpg @@ -190,6 +197,5 @@ Options -Indexes AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/json - AddOutputFilterByType DEFLATE image/x-icon diff --git a/www/breakdown.inc b/www/breakdown.inc index f09c3355b1..869408a715 100644 --- a/www/breakdown.inc +++ b/www/breakdown.inc @@ -11,27 +11,33 @@ if(extension_loaded('newrelic')) { * * @param mixed $requests */ -function getBreakdown($id, $testPath, $run, $cached, &$requests) +function getBreakdown($id, $testPath, $run, $cached, &$requests, $eventName = null) { - $cache = array(); - $cache_file = "$testPath/breakdown.json"; - if (is_file($cache_file)) { - $cache = json_decode(file_get_contents($cache_file), true); - } +// $cache = array(); +// $cache_file = "$testPath/breakdown.json"; +// if (is_file($cache_file)) { +// $cache = json_decode(file_get_contents($cache_file), true); +// } - if (array_key_exists("run_$run", $cache)) { - if (array_key_exists("cached_$cached", $cache["run_$run"])) { - $breakdown = $cache["run_$run"]["cached_$cached"]; - } - } else { - $cache["run_$run"] = array("cached_$cached" => array()); - } +// if (array_key_exists("run_$run", $cache)) { +// if (array_key_exists("cached_$cached", $cache["run_$run"])) { +// $breakdown = $cache["run_$run"]["cached_$cached"]; +// } +// } else { +// $cache["run_$run"] = array("cached_$cached" => array()); +// } if (!isset($breakdown)) { // get all of the requests $secure = false; $haveLocations = false; + if($eventName != null){ + $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, false, true); + $requestsArray = $requests[$eventName]; + } else { $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false); + $requestsArray = $requests; + } $breakdown = array(); $mime_colors = MimeColors(); @@ -44,7 +50,7 @@ function getBreakdown($id, $testPath, $run, $cached, &$requests) $breakdown["$contentType"] = $entry; } - foreach($requests as $request) { + foreach($requestsArray as $request) { $contentType = ContentType($request['contentType']); $object = strtolower($request['url']); if( strlen($contentType) && (stripos($object, 'favicon.ico') === FALSE) ) { diff --git a/www/breakdown.php b/www/breakdown.php index 2c6dea67a8..64942071fd 100644 --- a/www/breakdown.php +++ b/www/breakdown.php @@ -1,4 +1,5 @@ @@ -52,36 +60,37 @@ $tab = 'Test Result'; $subtab = 'Content Breakdown'; include 'header.inc'; - ?> - + foreach(array_keys($requests) as $eventName) + { ?> +


-

Content breakdown by MIME type (First View)

+

Content breakdown by MIME type (First View) -

-
+
-
+
-
+
-
+
-

Connection View (First View)

- +

Connection View (First View) -

+ $id, 'path' => $testPath, @@ -116,39 +125,42 @@
"> + echo "/waterfall.$extension?width=930&type=connection&test=$id&run=$run&mime=1&cached=0&eventName=$eventName";?>">
- - +


-

Content breakdown by MIME type (Repeat View)

+

Content breakdown by MIME type (Repeat View) -

-
+
-
+
-
+
-
+
-

Connection View (Repeat View)

- +

Connection View (Repeat View) -

+ $id, 'path' => $testPath, @@ -183,9 +195,11 @@
"> + echo "/waterfall.$extension?width=930&type=connection&test=$id&run=$run&mime=1&cached=1&eventName=$eventName";?>">
- + @@ -198,24 +212,28 @@ google.load('visualization', '1', {'packages':['table', 'corechart']}); google.setOnLoadCallback(drawTable); function drawTable() { + + var dataFv = new google.visualization.DataTable(); dataFv.addColumn('string', 'MIME Type'); dataFv.addColumn('number', 'Requests'); dataFv.addColumn('number', 'Bytes'); - dataFv.addRows(); + dataFv.addRows(); var fvRequests = new google.visualization.DataTable(); fvRequests.addColumn('string', 'Content Type'); fvRequests.addColumn('number', 'Requests'); - fvRequests.addRows(); + fvRequests.addRows(); var fvColors = new Array(); var fvBytes = new google.visualization.DataTable(); fvBytes.addColumn('string', 'Content Type'); fvBytes.addColumn('number', 'Bytes'); - fvBytes.addRows(); + fvBytes.addRows(); $data) + ksort($breakdownFv[$eventName]); + foreach($breakdownFv[$eventName] as $type => $data) { echo "dataFv.setValue($index, 0, '$type');\n"; echo "dataFv.setValue($index, 1, {$data['requests']});\n"; @@ -229,46 +247,49 @@ function drawTable() { $index++; } ?> - + var viewRequestsFv = new google.visualization.DataView(dataFv); viewRequestsFv.setColumns([0, 1]); - var tableRequestsFv = new google.visualization.Table(document.getElementById('tableRequestsFv_div')); + var tableRequestsFv = new google.visualization.Table(document.getElementById('tableRequestsFv_div_')); tableRequestsFv.draw(viewRequestsFv, {showRowNumber: false, sortColumn: 1, sortAscending: false}); - + var viewBytesFv = new google.visualization.DataView(dataFv); viewBytesFv.setColumns([0, 2]); - var tableBytesFv = new google.visualization.Table(document.getElementById('tableBytesFv_div')); + var tableBytesFv = new google.visualization.Table(document.getElementById('tableBytesFv_div_')); tableBytesFv.draw(viewBytesFv, {showRowNumber: false, sortColumn: 1, sortAscending: false}); - var pieRequestsFv = new google.visualization.PieChart(document.getElementById('pieRequestsFv_div')); + var pieRequestsFv = new google.visualization.PieChart(document.getElementById('pieRequestsFv_div_')); google.visualization.events.addListener(pieRequestsFv, 'ready', function(){markUserTime('aft.Requests Pie');}); pieRequestsFv.draw(fvRequests, {width: 450, height: 300, title: 'Requests', colors: fvColors}); - - var pieBytesFv = new google.visualization.PieChart(document.getElementById('pieBytesFv_div')); + + var pieBytesFv = new google.visualization.PieChart(document.getElementById('pieBytesFv_div_')); google.visualization.events.addListener(pieBytesFv, 'ready', function(){markUserTime('aft.Bytes Pie');}); pieBytesFv.draw(fvBytes, {width: 450, height: 300, title: 'Bytes', colors: fvColors}); - - + var dataRv = new google.visualization.DataTable(); dataRv.addColumn('string', 'MIME Type'); dataRv.addColumn('number', 'Requests'); dataRv.addColumn('number', 'Bytes'); - dataRv.addRows(); + dataRv.addRows(); var rvRequests = new google.visualization.DataTable(); rvRequests.addColumn('string', 'Content Type'); rvRequests.addColumn('number', 'Requests'); - rvRequests.addRows(); + rvRequests.addRows(); var rvColors = new Array(); var rvBytes = new google.visualization.DataTable(); rvBytes.addColumn('string', 'Content Type'); rvBytes.addColumn('number', 'Bytes'); - rvBytes.addRows(); + rvBytes.addRows(); $data) + ksort($breakdownRv[$eventName]); + foreach($breakdownRv[$eventName] as $type => $data) { echo "dataRv.setValue($index, 0, '$type');\n"; echo "dataRv.setValue($index, 1, {$data['requests']});\n"; @@ -282,25 +303,26 @@ function drawTable() { $index++; } ?> - + var viewRequestsRv = new google.visualization.DataView(dataRv); viewRequestsRv.setColumns([0, 1]); - var tableRequestsRv = new google.visualization.Table(document.getElementById('tableRequestsRv_div')); + var tableRequestsRv = new google.visualization.Table(document.getElementById('tableRequestsRv_div_')); tableRequestsRv.draw(viewRequestsRv, {showRowNumber: false, sortColumn: 1, sortAscending: false}); - + var viewBytesRv = new google.visualization.DataView(dataRv); viewBytesRv.setColumns([0, 2]); - var tableBytesRv = new google.visualization.Table(document.getElementById('tableBytesRv_div')); + var tableBytesRv = new google.visualization.Table(document.getElementById('tableBytesRv_div_')); tableBytesRv.draw(viewBytesRv, {showRowNumber: false, sortColumn: 1, sortAscending: false}); - - var pieRequestsRv = new google.visualization.PieChart(document.getElementById('pieRequestsRv_div')); + + var pieRequestsRv = new google.visualization.PieChart(document.getElementById('pieRequestsRv_div_')); pieRequestsRv.draw(rvRequests, {width: 450, height: 300, title: 'Requests', colors: rvColors}); - - var pieBytesRv = new google.visualization.PieChart(document.getElementById('pieBytesRv_div')); + + var pieBytesRv = new google.visualization.PieChart(document.getElementById('pieBytesRv_div_')); pieBytesRv.draw(rvBytes, {width: 450, height: 300, title: 'Bytes', colors: rvColors}); - + } diff --git a/www/customWaterfall.php b/www/customWaterfall.php index e5c2cccb09..6ae2ec0fe4 100644 --- a/www/customWaterfall.php +++ b/www/customWaterfall.php @@ -2,6 +2,7 @@ include 'common.inc'; $page_keywords = array('Custom','Waterfall','Webpagetest','Website Speed Test'); $page_description = "Website speed test custom waterfall$testLabel"; +$eventName = urldecode($_GET['eventName']); ?> @@ -25,7 +26,9 @@   By MIME Type
Image Width: Pixels (300-2000)
Maximum Time: Seconds (leave blank for automatic)
- Requests (i.e. 1,2,3,4-9,8): + Event Name:
+ Requests (i.e. 1,2,3,4-9,8):
+ Hosts (i.e. hostA,hostB):
Show CPU Utilization Show Bandwidth Utilization @@ -38,7 +41,7 @@ $extension = 'php'; if( FRIENDLY_URLS ) $extension = 'png'; - echo "\"Waterfall\""; + echo "\"Waterfall\""; ?> @@ -83,7 +86,9 @@ function UpdateWaterfall() mime = 1; var width = $('#width').val(); var max = $('#max').val(); + var event = $('#event').val(); var requests = $('#requests').val(); + var hosts = $('#hosts').val(); var showCPU = 0; if( $('#showCPU').attr('checked') ) showCPU = 1; @@ -101,20 +106,22 @@ function UpdateWaterfall() echo "var testRun='$run';\n"; echo "var cached='$cached';\n"; echo "var extension='$extension';\n"; - ?> - - var src = '/waterfall.' + extension + '?test=' + testId + - '&run=' + testRun + - '&cached=' + cached + - '&max=' + max + - '&width=' + width + - '&type=' + type + - '&mime=' + mime + - '&cpu=' + showCPU + - '&bw=' + showBW + - '&dots=' + showDots + - '&labels=' + showLabels + - '&requests=' + requests; + ?> + + var src = '/waterfall.' + extension + + '?test=' + testId + + '&run=' + testRun + + '&cached=' + cached + + '&max=' + max + + '&width=' + width + + '&type=' + type + + '&cpu=' + showCPU + + '&bw=' + showBW + + '&dots=' + showDots + + '&labels=' + showLabels + + '&requests=' + requests + + '&eventName=' + event + + '&hosts=' + hosts; $('#waterfallImage').attr("src", src); }; diff --git a/www/details.php b/www/details.php index a1ce51649a..3d61a73f9c 100644 --- a/www/details.php +++ b/www/details.php @@ -1,4 +1,6 @@ $_REQUEST['end']); -$data = loadPageRunData($testPath, $run, $cached, $options); + $options = array('end' => $_REQUEST['end']); +$dataArray = loadPageRunData($testPath, $run, $cached, array('SpeedIndex' => true), true); $page_keywords = array('Performance Test','Details','Webpagetest','Website Speed Test','Page Speed'); $page_description = "Website performance test details$testLabel"; ?> - - WebPagetest Test Details<?php echo $testLabel; ?> - - - - -
- - -
-
-
- -
- Export HTTP Archive (.har)'; - if ( is_dir('./google') && array_key_exists('enable_google_csi', $settings) && $settings['enable_google_csi'] ) - echo '
CSI (.csv) data'; - if( is_file("$testPath/{$run}{$cachedText}_dynaTrace.dtas") ) - { - echo "
Download dynaTrace Session"; - echo ' (get dynaTrace)'; - } - if( is_file("$testPath/{$run}{$cachedText}_bodies.zip") ) - echo "
Download Response Bodies"; - echo '
'; - ?> -
-
-
- - - 0.0) - $cols++; - if (array_key_exists('domTime', $data) && (float)$data['domTime'] > 0.0) - $cols++; - if (array_key_exists('aft', $test['test']) && $test['test']['aft'] ) - $cols++; - if (array_key_exists('domElements', $data) && $data['domElements'] > 0) - $cols++; - if (array_key_exists('SpeedIndex', $data) && (int)$data['SpeedIndex'] > 0) - $cols++; - if (array_key_exists('visualComplete', $data) && (float)$data['visualComplete'] > 0.0) - $cols++; - ?> - - - - - - - - - 0.0 ) { ?> - - - - - - 0.0) { ?> - - - 0) { ?> - - - 0.0 ) { ?> - - - 0 ) { ?> - - - - - - - - - - - - - - " . formatMsInterval($data['loadTime'], 3) . "\n"; - echo "\n"; - //echo "\n"; - echo "\n"; - if (array_key_exists('userTime', $data) && (float)$data['userTime'] > 0.0 ) - echo "\n"; - if (array_key_exists('aft', $test['test']) && $test['test']['aft'] ) { +td { + white-space: nowrap; + text-align: left; + vertical-align: middle; +} + +td.center { + text-align: center; +} + +table.details { + margin-left: auto; + margin-right: auto; + background: whitesmoke; + border-collapse: collapse; +} + +table.details th,table.details td { + border: 1px silver solid; + padding: 0.2em; + text-align: center; + font-size: smaller; +} + +table.details th { + background: gainsboro; +} + +table.details caption { + margin-left: inherit; + margin-right: inherit; + background: whitesmoke; +} + +table.details th.reqUrl,table.details td.reqUrl { + text-align: left; + width: 30em; + word-wrap: break-word; +} + +table.details td.even { + background: gainsboro; +} + +table.details td.odd { + background: whitesmoke; +} + +table.details td.evenRender { + background: #dfffdf; +} + +table.details td.oddRender { + background: #ecffec; +} + +table.details td.evenDoc { + background: #dfdfff; +} + +table.details td.oddDoc { + background: #ececff; +} + +table.details td.warning { + background: #ffff88; +} + +table.details td.error { + background: #ff8888; +} + +.header_details { + display: none; +} + +.a_request { + cursor: pointer; +} + + + + +
+ + +
+
+
+ +
+ Export HTTP Archive (.har)'; + if ( is_dir('./google') && array_key_exists('enable_google_csi', $settings) && $settings['enable_google_csi'] ) + echo '
CSI (.csv) data'; + if( is_file("$testPath/{$run}{$cachedText}_dynaTrace.dtas") ) + { + echo "
Download dynaTrace Session"; + echo ' (get dynaTrace)'; + } + if( is_file("$testPath/{$run}{$cachedText}_bodies.zip") ) + echo "
Download Response Bodies"; + echo '
'; + ?> +
+
+
+

+ +

+
+
+
>Document CompleteFully Loaded
Load TimeFirst ByteStart RenderUser TimeAbove the FoldVisually CompleteSpeed IndexDOM ElementDOM ElementsResult (error code)TimeRequestsBytes InTimeRequestsBytes In
" . formatMsInterval($data['TTFB'], 3) . "" . number_format($data['render'] / 1000.0, 3) . "s" . formatMsInterval($data['render'], 3) . "" . formatMsInterval($data['userTime'], 3) . "
+ + ', 0.0, "float") ) + $cols++; + if (array_key_exists('domTime', $data) && (float)$data['domTime'] > 0.0) + $cols++; + if( checkForAllEventNames($dataArray, 'domElements', '>', 0) ) + $cols++; + if( checkForAllEventNames($dataArray, 'SpeedIndex', '>', 0.0, "float") ) + $cols++; + if (array_key_exists('SpeedIndex', $data) && (int)$data['SpeedIndex'] > 0) + $cols++; + if (array_key_exists('visualComplete', $data) && (float)$data['visualComplete'] > 0.0) + $cols++; + ?> + + + + + + + + + + 0.0 ) { ?> + + + + + + ', 0.0, "float")) { ?> + + + ', 0, "int") ) { ?> + + + ', 0.0, "float") ) { ?> + + + ', 0)) { ?> + + + + + + + + + + + + + $data) {?> + + " . $eventName . "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + if (array_key_exists('userTime', $data) && (float)$data['userTime'] > 0.0 ) + echo "\n"; + if (array_key_exists('aft', $test['test']) && $test['test']['aft'] ) { $aft = number_format($data['aft'] / 1000.0, 1) . 's'; if( !$data['aft'] ) - $aft = 'N/A'; + $aft = 'N/A'; echo "\n"; + echo "\n"; if( array_key_exists('SpeedIndex', $data) && (int)$data['SpeedIndex'] > 0 ) { if (array_key_exists('SpeedIndexCustom', $data)) - echo "\n"; + echo "\n"; else - echo "\n"; + echo "\n"; } if (array_key_exists('domTime', $data) && (float)$data['domTime'] > 0.0 ) - echo "\n"; + echo "\n"; if (array_key_exists('domElements', $data) && $data['domElements'] > 0 ) - echo "\n"; - echo "\n"; + echo "\n"; + $resultCode = $data['result']; + if(!isset($resultCode) || $resultCode === null || $resultCode === ""){ + $resultCode = " "; + } + echo "\n"; echo "\n"; echo "\n"; @@ -219,136 +268,256 @@ echo "\n"; echo "\n"; ?> - -
>Document + CompleteFully + Loaded
Event NameLoad TimeFirst ByteStart RenderUser TimeAbove the FoldVisually CompleteSpeed IndexDOM ElementDOM ElementsResult (error code)TimeRequestsBytes InTimeRequestsBytes In
" . formatMsInterval($data['loadTime'], 3) . "" . formatMsInterval($data['TTFB'], 3) . "" . number_format($data['render'] / 1000.0, 3) . "s" . formatMsInterval($data['render'], 3) . "" . formatMsInterval($data['userTime'], 3) . "$aft"; } if( array_key_exists('visualComplete', $data) && (float)$data['visualComplete'] > 0.0 ) - echo "" . formatMsInterval($data['visualComplete'], 3) . "" . formatMsInterval($data['visualComplete'], 3) . "{$data['SpeedIndexCustom']}{$data['SpeedIndexCustom']}{$data['SpeedIndex']}{$data['SpeedIndex']}" . formatMsInterval($data['domTime'], 3) . "" . formatMsInterval($data['domTime'], 3) . "{$data['domElements']}{$data['result']}{$data['domElements']}{$resultCode}" . formatMsInterval($data['docTime'], 3) . "{$data['requestsDoc']}{$data['requests']}" . number_format($data['bytesIn'] / 1024, 0) . " KB

- -

Csi Metrics

- - - ' . $csi_param . ''; - echo ''; - foreach ( $test['testinfo']['extract_csi'] as $csi_param ) - { - if( array_key_exists($csi_param, $params) ) - { - echo ''; - } - else - { - echo ''; - } - } - echo ''; - ?> -
' . $params[$csi_param] . '

- $value) - if (substr($metric, 0, 9) == 'userTime.') - $userTimings[substr($metric, 9)] = $value; - $timingCount = count($userTimings); - $navTiming = false; - if ((array_key_exists('loadEventStart', $data) && $data['loadEventStart'] > 0) || + + + +
+ +

Csi Metrics

+ + + ' . $csi_param . ''; + echo ''; + foreach ( $test['testinfo']['extract_csi'] as $csi_param ) + { + if( array_key_exists($csi_param, $params) ) + { + echo ''; + } + else + { + echo ''; + } + } + echo ''; + ?> + +
' . $params[$csi_param] . '
+
+ $value) + if (substr($metric, 0, 9) == 'userTime.') + $userTimings[substr($metric, 9)] = $value; + $timingCount = count($userTimings); + $navTiming = false; + if ((array_key_exists('loadEventStart', $data) && $data['loadEventStart'] > 0) || (array_key_exists('domContentLoadedEventStart', $data) && $data['domContentLoadedEventStart'] > 0)) $navTiming = true; if ($timingCount || $navTiming) { - $borderClass = ''; - if ($timingCount) - $borderClass = ' class="border"'; - echo ''; - echo ''; - if ($timingCount) - foreach($userTimings as $label => $value) - echo ''; - if ($navTiming) { + $borderClass = ''; + if ($timingCount) + $borderClass = ' class="border"'; + echo '
' . htmlspecialchars($label) . '
'; + echo ''; + echo ''; + if ($timingCount) + foreach($userTimings as $label => $value) + echo ''; + if ($navTiming) { echo ""; if ($data['firstPaint'] > 0) - echo "msFirstPaint"; } echo ''; if ($timingCount) - foreach($userTimings as $label => $value) - echo ''; + foreach($userTimings as $label => $value) + echo ''; if ($navTiming) { - echo ""; - if ($data['firstPaint'] > 0) - echo number_format($data['firstPaint'] / 1000.0, 3) . 's'; - echo ''; + foreach($dataArray as $eventName => $data) { + echo ""; + echo ""; + if ($data['firstPaint'] > 0) + echo number_format($data['firstPaint'] / 1000.0, 3) . 's'; } - echo ''; - echo '
Event Name' . htmlspecialchars($label) . '"; + echo "msFirstPaint"; echo "domContentLoadedloadEvent
' . number_format($value / 1000, 3) . 's' . number_format($value / 1000, 3) . 's'; - echo number_format($data['domContentLoadedEventStart'] / 1000.0, 3) . 's - ' . - number_format($data['domContentLoadedEventEnd'] / 1000.0, 3) . 's (' . - number_format(($data['domContentLoadedEventEnd'] - $data['domContentLoadedEventStart']) / 1000.0, 3) . 's)' . '' . number_format($data['loadEventStart'] / 1000.0, 3) . 's - ' . - number_format($data['loadEventEnd'] / 1000.0, 3) . 's (' . - number_format(($data['loadEventEnd'] - $data['loadEventStart']) / 1000.0, 3) . 's)' . '
$eventName'; + echo number_format($data['domContentLoadedEventStart'] / 1000.0, 3) . 's - ' . + number_format($data['domContentLoadedEventEnd'] / 1000.0, 3) . 's (' . + number_format(($data['domContentLoadedEventEnd'] - $data['domContentLoadedEventStart']) / 1000.0, 3) . 's)'; + echo ''; + echo number_format($data['loadEventStart'] / 1000.0, 3) . 's - ' . + number_format($data['loadEventEnd'] / 1000.0, 3) . 's (' . + number_format(($data['loadEventEnd'] - $data['loadEventStart']) / 1000.0, 3) . 's)'; + echo '

'; + } + echo '
'; } $secure = false; $haveLocations = false; - $requests = getRequests($id, $testPath, $run, @$_GET['cached'], $secure, $haveLocations, true, true); + $requests = getRequests($id, $testPath, $run, @$_GET['cached'], $secure, $haveLocations, true, true, true); ?> - -
-

Waterfall View

- - - - - - - - - - - - -
DNS Lookup
Initial Connection
SSL Negotiation
Time to First Byte
Content Download
 3xx response 
 4xx+ response 
- - - -
Start Render
Above the Fold
'; - if (array_key_exists('domTime', $data) && (float)$data['domTime'] > 0.0 ) - echo '
DOM Element
'; - if(array_key_exists('firstPaint', $data) && (float)$data['firstPaint'] > 0.0 ) - echo '
msFirstPaint
'; - if(array_key_exists('domContentLoadedEventStart', $data) && (float)$data['domContentLoadedEventStart'] > 0.0 ) - echo '
DOM Content Loaded
'; - if(array_key_exists('loadEventStart', $data) && (float)$data['loadEventStart'] > 0.0 ) - echo '
On Load
'; - echo '
Document Complete
'; - if(array_key_exists('userTime', $data) || (array_key_exists('enable_google_csi', $settings) && $settings['enable_google_csi'])) - echo '
User Timings
'; - ?> - - -
- customize waterfall • "; - echo "View all Images"; - ?> -
-
-

Connection View

- - +
+ +

Quicklinks

+ Back to page top + + + + + + + + + + + + + + + + + + + + + + + +
Event NameWaterfall ViewConnection ViewRequest DetailsRequest HeadersCustomize WaterfallView all Images
WV + # + CV + # + RD + # + RH + # + >CW + # + >VaI + # +
+
+


+
+ $data) + { ?> + +

+ Waterfall View - + +

+ Back to Quicklinks + + + + + + + + + + + + +
+ + + + +
DNS Lookup
+ + + + +
Initial Connection
+ + + + +
SSL Negotiation
+ + + + +
Time to First Byte
+ + + + +
Content Download
 3xx response 
+
 4xx+ response 
+
+ + + +
+ + + + +
Start Render
Above the Fold
'; + if (array_key_exists('domTime', $data) && (float)$data['domTime'] > 0.0 ) + echo '
DOM Element
'; + if(array_key_exists('firstPaint', $data) && (float)$data['firstPaint'] > 0.0 ) + echo '
msFirstPaint
'; + if(array_key_exists('domContentLoadedEventStart', $data) && (float)$data['domContentLoadedEventStart'] > 0.0 ) + echo '
DOM Content Loaded
'; + if(array_key_exists('loadEventStart', $data) && (float)$data['loadEventStart'] > 0.0 ) + echo '
On Load
'; + echo '
Document Complete
'; + if(array_key_exists('userTime', $data) || (array_key_exists('enable_google_csi', $settings) && $settings['enable_google_csi'])) + echo '
User Timings
'; + ?> + + +
+ + customize waterfall • "; + echo "View all Images (for event name $eventName)"; + echo "


"; + } + ?> + $data) + { ?> + +

+ Connection View - + +

+ Back to Quicklinks + + $id, 'path' => $testPath, 'run_id' => $run, @@ -367,46 +536,102 @@ echo "\"{$entry['url']}\"\n"; } } - ?> - - - - - - - - - - 0.0 ) { ?> - - - 0.0 ) { ?> - - - 0.0 ) { ?> - - - - -
DNS Lookup
Initial Connection
SSL Negotiation
Start Render
DOM Element
DOM Content Loaded
On Load
Document Complete
-
- Connection View waterfall diagram + + + + + + +
DNS Lookup
+ + + + + +
Initial Connection
+ + + + + + +
SSL Negotiation
+ + + + + + +
Start Render
+ ', 0.0, "float") ) { ?> + + + + + +
DOM Element
+ + 0.0 ) { ?> + + + + + +
DOM Content Loaded
+ + 0.0 ) { ?> + + + + + +
On Load
+ + + + + + +
Document Complete
+ + +
Connection View waterfall diagram"> -
-

- + $extension = 'png'; + echo "/waterfall.$extension?type=connection&width=930&test=$id&run=$run&cached=$cached&mime=1&eventName=$eventName";?>"> +


+ +
+ + -
- -
+
+ + +
- - + + - - + diff --git a/www/domains.inc b/www/domains.inc index 0fee667ca4..17c1c7dc12 100644 --- a/www/domains.inc +++ b/www/domains.inc @@ -6,19 +6,28 @@ require 'object_detail.inc'; * * @param mixed $requests */ -function getDomainBreakdown($id, $testPath, $run, $cached, &$requests) +function getDomainBreakdown($id, $testPath, $run, $cached, &$requests, $eventName = null) { // get all of the requests if (!isset($requests) || !count($requests)) { $secure = false; $haveLocations = false; + if($eventName != null){ + $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, false, true); + } else { $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false); } + } + if($eventName != null){ + $requestsArray = $requests[$eventName]; + } else { + $requestsArray = $requests; + } $breakdown = array(); $connections = array(); - foreach($requests as $request) + foreach($requestsArray as $request) { $domain = strrev(strtok($request['host'],':')); $object = strtolower($request['url']); diff --git a/www/domains.php b/www/domains.php index 2900177018..befb74ef60 100644 --- a/www/domains.php +++ b/www/domains.php @@ -1,4 +1,5 @@ @@ -44,59 +53,64 @@ - + include 'header.inc'; + foreach(array_keys($requests) as $eventName) + { ?> +


-

Content breakdown by domain (First View)

+

Content breakdown by domain (First View) -

-
+
-
+
-
+
-
+
- - +


-

Content breakdown by domain (Repeat View)

+

Content breakdown by domain (Repeat View) -

-
+
-
+
-
+
-
+
- + @@ -109,23 +123,26 @@ google.load('visualization', '1', {'packages':['table', 'corechart']}); google.setOnLoadCallback(drawTable); function drawTable() { + var dataFv = new google.visualization.DataTable(); dataFv.addColumn('string', 'Domain'); dataFv.addColumn('number', 'Requests'); dataFv.addColumn('number', 'Bytes'); - dataFv.addRows(); + dataFv.addRows(); var fvRequests = new google.visualization.DataTable(); fvRequests.addColumn('string', 'Domain'); fvRequests.addColumn('number', 'Requests'); - fvRequests.addRows(); + fvRequests.addRows(); var fvBytes = new google.visualization.DataTable(); fvBytes.addColumn('string', 'Domain'); fvBytes.addColumn('number', 'Bytes'); - fvBytes.addRows(); + fvBytes.addRows(); $data) + ksort($breakdownFv[$eventName]); + foreach($breakdownFv[$eventName] as $domain => $data) { $domain = strrev($domain); echo "dataFv.setValue($index, 0, '$domain');\n"; @@ -136,47 +153,50 @@ function drawTable() { echo "fvBytes.setValue($index, 0, '$domain');\n"; echo "fvBytes.setValue($index, 1, {$data['bytes']});\n"; $index++; - } - ?> + } ?> var viewRequestsFv = new google.visualization.DataView(dataFv); viewRequestsFv.setColumns([0, 1]); - var tableRequestsFv = new google.visualization.Table(document.getElementById('tableRequestsFv_div')); + var tableRequestsFv = new google.visualization.Table(document.getElementById('tableRequestsFv_div_')); tableRequestsFv.draw(viewRequestsFv, {showRowNumber: false, sortColumn: 1, sortAscending: false}); - + var viewBytesFv = new google.visualization.DataView(dataFv); viewBytesFv.setColumns([0, 2]); - var tableBytesFv = new google.visualization.Table(document.getElementById('tableBytesFv_div')); + var tableBytesFv = new google.visualization.Table(document.getElementById('tableBytesFv_div_')); tableBytesFv.draw(viewBytesFv, {showRowNumber: false, sortColumn: 1, sortAscending: false}); - - var pieRequestsFv = new google.visualization.PieChart(document.getElementById('pieRequestsFv_div')); + + var pieRequestsFv = new google.visualization.PieChart(document.getElementById('pieRequestsFv_div_')); google.visualization.events.addListener(pieRequestsFv, 'ready', function(){markUserTime('aft.Requests Pie');}); pieRequestsFv.draw(fvRequests, {width: 450, height: 300, title: 'Requests'}); - - var pieBytesFv = new google.visualization.PieChart(document.getElementById('pieBytesFv_div')); + + var pieBytesFv = new google.visualization.PieChart(document.getElementById('pieBytesFv_div_')); google.visualization.events.addListener(pieBytesFv, 'ready', function(){markUserTime('aft.Bytes Pie');}); pieBytesFv.draw(fvBytes, {width: 450, height: 300, title: 'Bytes'}); - + var dataRv = new google.visualization.DataTable(); dataRv.addColumn('string', 'Domain'); dataRv.addColumn('number', 'Requests'); dataRv.addColumn('number', 'Bytes'); - dataRv.addRows(); + dataRv.addRows(); var rvRequests = new google.visualization.DataTable(); rvRequests.addColumn('string', 'Domain'); rvRequests.addColumn('number', 'Requests'); - rvRequests.addRows(); + rvRequests.addRows(); var rvBytes = new google.visualization.DataTable(); rvBytes.addColumn('string', 'Domain'); rvBytes.addColumn('number', 'Bytes'); - rvBytes.addRows(); + rvBytes.addRows(); $data) + ksort($breakdownRv[$eventName]); + foreach($breakdownRv[$eventName] as $domain => $data) { $domain = strrev($domain); echo "dataRv.setValue($index, 0, '$domain');\n"; @@ -193,21 +213,22 @@ function drawTable() { var viewRequestsRv = new google.visualization.DataView(dataRv); viewRequestsRv.setColumns([0, 1]); - var tableRequestsRv = new google.visualization.Table(document.getElementById('tableRequestsRv_div')); + var tableRequestsRv = new google.visualization.Table(document.getElementById('tableRequestsRv_div_')); tableRequestsRv.draw(viewRequestsRv, {showRowNumber: false, sortColumn: 1, sortAscending: false}); var viewBytesRv = new google.visualization.DataView(dataRv); viewBytesRv.setColumns([0, 2]); - var tableBytesRv = new google.visualization.Table(document.getElementById('tableBytesRv_div')); + var tableBytesRv = new google.visualization.Table(document.getElementById('tableBytesRv_div_')); tableBytesRv.draw(viewBytesRv, {showRowNumber: false, sortColumn: 1, sortAscending: false}); - var pieRequestsRv = new google.visualization.PieChart(document.getElementById('pieRequestsRv_div')); + var pieRequestsRv = new google.visualization.PieChart(document.getElementById('pieRequestsRv_div_')); pieRequestsRv.draw(rvRequests, {width: 450, height: 300, title: 'Requests'}); - var pieBytesRv = new google.visualization.PieChart(document.getElementById('pieBytesRv_div')); + var pieBytesRv = new google.visualization.PieChart(document.getElementById('pieBytesRv_div_')); pieBytesRv.draw(rvBytes, {width: 450, height: 300, title: 'Bytes'}); - + } diff --git a/www/export.php b/www/export.php index 65ee112479..78115ef28f 100644 --- a/www/export.php +++ b/www/export.php @@ -1,10 +1,10 @@ encode($result); } - + // see if we need to wrap it in a JSONP callback if( isset($_REQUEST['callback']) && strlen($_REQUEST['callback']) ) echo "{$_REQUEST['callback']}("; - + // send the actual JSON data echo $out; - + if( isset($_REQUEST['callback']) && strlen($_REQUEST['callback']) ) echo ");"; } @@ -69,7 +75,7 @@ function msdate($mstimestamp) { $timestamp = floor($mstimestamp); $milliseconds = round(($mstimestamp - $timestamp) * 1000); - + $date = gmdate('c', $timestamp); $msDate = substr($date, 0, 19) . '.' . sprintf('%03d', $milliseconds) . substr($date, 19); @@ -92,17 +98,17 @@ function durationOfInterval($value) { } /** -* Build the data set -* -* @param mixed $pageData -*/ + * Build the data set + * + * @param mixed $pageData + */ function BuildResult(&$pageData) { global $id; global $testPath; $result = array(); $entries = array(); - + $result['log'] = array(); $result['log']['version'] = '1.1'; $result['log']['creator'] = array( @@ -110,7 +116,8 @@ function BuildResult(&$pageData) 'version' => '1.8' ); $result['log']['pages'] = array(); - foreach ($pageData as $run => $pageRun) { + foreach($pageData as $eventName => $pageDataArray){ + foreach ($pageDataArray as $run => $pageRun) { foreach ($pageRun as $cached => $data) { $cached_text = ''; if ($cached) @@ -124,19 +131,20 @@ function BuildResult(&$pageData) $pd = array(); $pd['startedDateTime'] = msdate($data['date']); $pd['title'] = "Run $run, "; + $pd['title'] .= "Event Name $eventName, "; if( $cached ) $pd['title'] .= "Repeat View"; else $pd['title'] .= "First View"; $pd['title'] .= " for " . $data['URL']; - $pd['id'] = "page_{$run}_{$cached}"; + $pd['id'] = "page_{$run}_{$eventName}_{$cached}"; $pd['pageTimings'] = array( 'onLoad' => $data['docTime'], 'onContentLoad' => -1, '_startRender' => $data['render'] ); - + // add the pagespeed score $score = GetPageSpeedScore("$testPath/{$run}{$cached_text}_pagespeed.txt"); if( strlen($score) ) $pd['_pageSpeed'] = array( 'score' => $score ); - + // dump all of our metrics into the har data as custom fields foreach($data as $name => $value) { if (!is_array($value)) @@ -145,18 +153,17 @@ function BuildResult(&$pageData) // add the page-level ldata to the result $result['log']['pages'][] = $pd; - // now add the object-level data to the result $secure = false; $haveLocations = false; - $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, true); - foreach( $requests as &$r ) + $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, true, true); + foreach( $requests[$eventName] as &$r ) { $entry = array(); $entry['pageref'] = $pd['id']; $entry['startedDateTime'] = msdate((double)$data['date'] + ($r['load_start'] / 1000.0)); $entry['time'] = $r['all_ms']; - + $request = array(); $request['method'] = $r['method']; $protocol = ($r['is_secure']) ? 'https://' : 'http://'; @@ -214,14 +221,14 @@ function BuildResult(&$pageData) foreach($qs as $name => $val) $request['queryString'][] = array('name' => (string)$name, 'value' => (string)$val ); } - + if( !strcasecmp(trim($request['method']), 'post') ) { $request['postData'] = array(); $request['postData']['mimeType'] = ''; $request['postData']['text'] = ''; } - + $entry['request'] = $request; $response = array(); @@ -243,7 +250,7 @@ function BuildResult(&$pageData) $val = (string)trim(substr($header, $pos + 1)); if( strlen($name) ) $response['headers'][] = array('name' => $name, 'value' => $val); - + if( !strcasecmp($name, 'location') ) $loc = (string)$val; } @@ -264,14 +271,14 @@ function BuildResult(&$pageData) $response['content']['mimeType'] = (string)$r['contentType']; else $response['content']['mimeType'] = ''; - + // unsupported fields that are required $response['cookies'] = array(); $entry['response'] = $response; - + $entry['cache'] = (object)array(); - + $timings = array(); $timings['blocked'] = -1; $timings['dns'] = (int)$r['dns_ms']; @@ -317,7 +324,7 @@ function BuildResult(&$pageData) $entry['time'] += $duration; } } - + if (array_key_exists('custom_rules', $r)) { $entry['_custom_rules'] = $r['custom_rules']; } @@ -333,9 +340,10 @@ function BuildResult(&$pageData) } } } - + } + $result['log']['entries'] = $entries; - + return $result; } ?> diff --git a/www/object_detail.inc b/www/object_detail.inc index 55d61f454f..8b0b42ba9b 100644 --- a/www/object_detail.inc +++ b/www/object_detail.inc @@ -1,5 +1,6 @@ &$request) { - $request['index'] = $index; - $request['number'] = $index + 1; - if (@$request['body']) - $request['body_url'] = "/response_body.php?test=$id&run=$run&cached=$is_cached&request={$request['number']}"; - if ($request['is_secure']) - $has_secure_requests = true; - if (isset($custom_rules) && is_array($custom_rules) && array_key_exists($index + 1, $custom_rules)) - $request['custom_rules'] = $custom_rules[$index + 1]; - } - + $requestsArray = LoadRequests($test_path, $request_file_name, $eventSeperated, $hosts); + if(!$eventSeperated){ + $tmp = $requestsArray; + $requestsArray = array(); + $requestsArray['none'] = $tmp; + } + $result = array(); + $eventNumber = 1; + foreach($requestsArray as $eventName => $requests){ + if (isset($requests) && is_array($requests) && count($requests)) { + if ($use_raw_headers) + $needHeaders = true; + + AddResponseBodyFlags($requests, $bodies_file_name); + + // load any custom checks if they are available + $custom_rules = array(); + if (gz_is_file($custom_rules_file_name)) + $custom_rules = json_decode(gz_file_get_contents($custom_rules_file_name), true); + } else + GetDevToolsRequests($test_path, $run, $is_cached, $requests, $pageData); + FixUpRequestTimes($requests); + if ($needHeaders){ + $oldFileName = $headers_file_name; + if(strcmp($headers_file_name, $file_prefix . 'report.txt') == 0){ + $headers_file_name = $file_prefix . $eventNumber++ . '_report.txt'; + } + AddHeaders($requests, $headers_file_name); + $headers_file_name = $oldFileName; + } + + $has_locations = false; + if ($use_location_check) { + $has_locations = AddLocationData($requests); + } + + $has_secure_requests = false; + foreach ($requests as $index => &$request) { + $request['index'] = $index; + $request['number'] = $index + 1; + if (@$request['body']) + $request['body_url'] = "/response_body.php?test=$id&run=$run&cached=$is_cached&request={$request['number']}"; + if ($request['is_secure']) + $has_secure_requests = true; + if (isset($custom_rules) && is_array($custom_rules) && array_key_exists($index + 1, $custom_rules)) + $request['custom_rules'] = $custom_rules[$index + 1]; + if(!$eventSeperated){ + $result[] = $request; + } + } + if($eventSeperated){ + $result[$eventName] = $requests; + } + } // this is disabled for right now - there were indications that it was // spiking CPU to 100% on WPT so there may be a loop condition of some kind //BuildRequestDependencies($requests); - - return $requests; + + return $result; } /** -* Compute where page load time is spent: downloading, requests, etc -* -* @param mixed $requests -*/ + * Compute where page load time is spent: downloading, requests, etc + * + * @param mixed $requests + */ function CalculateComponentTimes(&$pageData, &$requests) { // Figure out the appropriate end time. $end = $pageData['load_ms']; @@ -123,9 +146,13 @@ function CalculateComponentTimes(&$pageData, &$requests) { } /** -* Load the gzipped request file (tab deliminated). -*/ -function LoadRequests($request_file_name) { + * Load the gzipped request file (tab deliminated). + */ +function LoadRequests($testPath, $request_file_name, $eventSeperated) { + + if( gz_is_file("$testPath/testinfo.json") ) + $test_info = json_decode(gz_file_get_contents("$testPath/testinfo.json"), true); + $requests = array(); $needed_columns = array( // tsv_column => request_key @@ -182,21 +209,35 @@ function LoadRequests($request_file_name) { 74 => 'jpeg_scan_count', ); $request_lines = gz_file($request_file_name); + $eventName = ''; + $eventCount = 0; if( isset($request_lines) && is_array($request_lines)) { - foreach($request_lines as &$line) { - if (strncmp($line, "Date\t", 4)) { + if($hosts != null){ + $hostsArray = split(",", $hosts); + } + foreach($request_lines as $linenum => &$line) { $columns = explode("\t", str_replace("\t", "\t ", $line)); + // sequence number equals 1? + if(intval($columns[34]) == 1){ + $eventName = getFullEventName($test_info['label'], trim($columns[2]), $eventCount, $requests); + $requests[$eventName] = array(); + $eventCount++; + } if (count($columns)) { $request = array(); foreach ($columns as $i => $value) { if (array_key_exists($i + 1, $needed_columns) && strlen(trim($value))) $request[$needed_columns[$i + 1]] = trim($value); - } + } if (array_key_exists('host', $request) && array_key_exists('url', $request)) { $url = 'http://'; if (array_key_exists('is_secure', $request) && $request['is_secure']) $url = 'https://'; - $url .= $request['host'] . $request['url']; + if(strpos($request['url'], $request['host']) !== 0){ + $url .= $request['host']; + } + $url .= $request['url']; + $request['full_url'] = $url; } if (array_key_exists('jpeg_scan_count', $request)) { @@ -211,17 +252,20 @@ function LoadRequests($request_file_name) { } else $request['score_progressive_jpeg'] = -1; } - $requests[] = $request; - } - } - } - } + if($eventSeperated){ + $requests[$eventName][] = $request; + } else { + $requests[] = $request; + } + } + } + } return $requests; } /** -* Map IP addresses to country, countryCode, city, region, lat, and long. -*/ + * Map IP addresses to country, countryCode, city, region, lat, and long. + */ function AddLocationData(&$requests) { $has_locations = false; $geo_ip = null; @@ -235,10 +279,10 @@ function AddLocationData(&$requests) { if (isset($geo_ip)) { foreach($requests as &$request) { - if (array_key_exists('cdn_provider', $request) && + if (array_key_exists('cdn_provider', $request) && strlen($request['cdn_provider'])) { $request['location'] = $request['cdn_provider']; - } elseif (array_key_exists('cdn_score', $request) && + } elseif (array_key_exists('cdn_score', $request) && $request['cdn_score'] == 100) { $request['location'] = 'CDN'; } elseif ($request['ip_addr']) { @@ -270,16 +314,17 @@ function AddLocationData(&$requests) { } $request['location'] = $loc; } - } catch(Exception $e) {} + } catch(Exception $e) { } } } + } return $has_locations; } /** -* Convert old format for DNS/connection data. -*/ + * Convert old format for DNS/connection data. + */ function MergeDnsAndConnectionTimes($requests) { $merged_requests = array(); if (isset($requests) && is_array($requests)) { @@ -383,8 +428,8 @@ function FixUpRequestTimes(&$requests) { } /** -* Helper for AddHeaders to initialize variables. -*/ + * Helper for AddHeaders to initialize variables. + */ function _AddHeadersInit(&$index, &$headers, &$headers_key) { $index = null; $headers = array('request' => array(), 'response' => array()); @@ -392,8 +437,8 @@ function _AddHeadersInit(&$index, &$headers, &$headers_key) { } /** -* Helper for AddHeaders to save headers. -*/ + * Helper for AddHeaders to save headers. + */ function _AddHeadersSave(&$requests, &$index, &$headers) { if ((count($headers['request']) || count($headers['response'])) && array_key_exists($index, $requests)) { @@ -402,18 +447,20 @@ function _AddHeadersSave(&$requests, &$index, &$headers) { } /** -* Load the raw headers if we have them. -*/ + * Load the raw headers if we have them. + */ function AddHeaders(&$requests, $headers_file_name) { + $curEventNumber = 0; $header_lines = gz_file($headers_file_name); if ($header_lines) { $is_started = false; _AddHeadersInit($index, $headers, $headers_key); - foreach ($header_lines as &$line) { - $trimmed = trim($line); + foreach ($header_lines as &$line) { + $trimmed = trim($line); if (!$is_started) { $is_started = ($trimmed == 'Request details:'); - } else { + } + else { if ($trimmed == 'Request Headers:' && isset($index)) { $headers_key = 'request'; } elseif ($trimmed == 'Response Headers:' && isset($index)) { @@ -437,7 +484,7 @@ function AddHeaders(&$requests, $headers_file_name) { } /* -* Flag the requests that have a response body available. + * Flag the requests that have a response body available. */ function AddResponseBodyFlags(&$requests, $bodies_file_name) { if (is_file($bodies_file_name)) { @@ -454,10 +501,10 @@ function AddResponseBodyFlags(&$requests, $bodies_file_name) { } /** -* Get the request for the base page (first non-redirect) -* -* @param mixed $requests -*/ + * Get the request for the base page (first non-redirect) + * + * @param mixed $requests + */ function GetBasePage(&$requests) { $basePage = null; foreach($requests as &$request) { @@ -470,10 +517,10 @@ function GetBasePage(&$requests) { } /** -* Build the list of dependencies for each request -* -* @param mixed $requests -*/ + * Build the list of dependencies for each request + * + * @param mixed $requests + */ function BuildRequestDependencies(&$requests) { foreach($requests as &$request) { $request['loads'] = array(); @@ -481,18 +528,18 @@ function BuildRequestDependencies(&$requests) { $request['loaded_by'] = array(); RequestLoadedBy($request['number'], $requests, $request['loaded_by']); } - + return $dependencies; } /** -* Figure out all of the resources loaded by the given resource -* -* @param mixed $index -* @param mixed $requests -* @param mixed $map -* @param mixed $entry -*/ + * Figure out all of the resources loaded by the given resource + * + * @param mixed $index + * @param mixed $requests + * @param mixed $map + * @param mixed $entry + */ function RequestLoads($request_number, &$requests, &$entry) { $request = &$requests[$request_number - 1]; if (array_key_exists('full_url', $request)) { @@ -515,13 +562,13 @@ function RequestLoads($request_number, &$requests, &$entry) { } /** -* Figure out all of the resources required to load the given resource -* -* @param mixed $index -* @param mixed $requests -* @param mixed $map -* @param mixed $entry -*/ + * Figure out all of the resources required to load the given resource + * + * @param mixed $index + * @param mixed $requests + * @param mixed $map + * @param mixed $entry + */ function RequestLoadedBy($request_number, &$requests, &$entry) { $request = &$requests[$request_number - 1]; if (array_key_exists('initiator', $request)) { diff --git a/www/optimization.inc b/www/optimization.inc index 210c4a3b8e..f9af8e46b5 100644 --- a/www/optimization.inc +++ b/www/optimization.inc @@ -17,7 +17,10 @@ function dumpOptimizationReport(&$pageData, &$requests, $id, $run, $cached, &$te ReportImageCompression($pageData, $requests); ReportProgressiveJpeg($pageData, $requests); ReportCache($pageData, $requests); + ReportCombine($pageData, $requests); ReportCDN($pageData, $requests); + ReportMinify($pageData, $requests); + ReportCookies($pageData, $requests); } } @@ -72,7 +75,7 @@ function ReportKeepAlive(&$pageData, &$requests) echo "

Use persistent connections (keep alive): $score

\n"; foreach( $report as $entry ) - echo "$entry
\n"; + echo urldecode($entry)."
\n"; echo "


\n"; } @@ -125,7 +128,7 @@ function ReportTransferCompression(&$pageData, &$requests) echo "

$summary

\n"; echo "

"; foreach( $report as $entry ) - echo "$entry
\n"; + echo urldecode($entry)."
\n"; echo "


\n"; } @@ -178,7 +181,7 @@ function ReportImageCompression(&$pageData, &$requests) echo "

$summary

\n"; echo "

"; foreach( $report as $entry ) - echo "$entry
\n"; + echo urldecode($entry)."
\n"; echo "


\n"; } @@ -285,7 +288,7 @@ function ReportCache(&$pageData, &$requests) echo "

Leverage browser caching of static assets: $score

\n"; echo "

"; foreach( $report as $entry ) - echo "$entry
\n"; + echo urldecode($entry)."
\n"; echo "


\n"; } @@ -320,7 +323,7 @@ function ReportCombine(&$pageData, &$requests) echo "

Combine static CSS and JS files: $score

\n"; foreach( $report as $entry ) - echo "$entry
\n"; + echo urldecode($entry)."
\n"; echo "


\n"; } @@ -360,7 +363,7 @@ function ReportCDN(&$pageData, &$requests) echo "

Use a CDN for all static assets: $score

\n"; foreach( $report as $entry ) - echo "$entry
\n"; + echo urldecode($entry)."
\n"; if( count($cdns) ) { echo "
CDN's Used:
"; @@ -419,7 +422,7 @@ function ReportMinify(&$pageData, &$requests) echo "

$summary

\n"; echo "

"; foreach( $report as $entry ) - echo "$entry
\n"; + echo urldecode($entry)."
\n"; echo "


\n"; } @@ -454,7 +457,7 @@ function ReportCookies(&$pageData, &$requests) echo "

Proper cookie usage: $score

\n"; foreach( $report as $entry ) - echo "$entry
\n"; + echo urldecode($entry)."
\n"; echo "


\n"; } @@ -469,9 +472,14 @@ function dumpOptimizationGlossary(&$settings)

Glossary:

+ - + @@ -481,7 +489,7 @@ function dumpOptimizationGlossary(&$settings) - + @@ -491,7 +499,7 @@ function dumpOptimizationGlossary(&$settings) - + @@ -514,7 +522,7 @@ function dumpOptimizationGlossary(&$settings) - + @@ -524,7 +532,7 @@ function dumpOptimizationGlossary(&$settings) - + - + diff --git a/www/optimizationChecklist.php b/www/optimizationChecklist.php index dd887b1d42..1f288361bd 100644 --- a/www/optimizationChecklist.php +++ b/www/optimizationChecklist.php @@ -4,14 +4,15 @@ include 'object_detail.inc'; include 'optimizationChecklist.inc'; require_once('page_data.inc'); +$eventName = $_GET["eventName"]; $pageData = loadPageRunData($testPath, $run, $cached); // get all of the requests $secure = false; $haveLocations = false; -$requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false); +$requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, false, true); -$im = drawChecklist($url, $requests, $pageData); +$im = drawChecklist($url, $requests[$eventName], $pageData); // spit the image out to the browser imagepng($im); diff --git a/www/page_data.inc b/www/page_data.inc index 17da626665..68fe5011e4 100644 --- a/www/page_data.inc +++ b/www/page_data.inc @@ -1,486 +1,482 @@ $data){ + if( isset($data) ){ + $tmp[0] = $data; + } + + if( !$fvonly ) + { + unset( $data ); + $dataArray = loadPageRunData($testPath, $run, 1, $options, true); + $data = $dataArray[$eventName]; + if( isset($data) ) + $tmp[1] = $data; + } + foreach($tmp as $cached => $data){ + if($allEvents){ + $ret[$eventName][$run][$cached] = $data; + } else { + $ret[$run][$cached] = $data; + } + } + if(!$allEvents){ + break; + } + } + } + } + return $ret; } -/** -* Load the page data for the given run -* -* @param mixed $testPath -* @param mixed $run -* @param mixed $fv -* @param mixed $rv -*/ -function loadPageRunData($testPath, $run, $cached, $options = null) -{ - $ret = null; + /** + * Load the page data for the given run + * + * @param mixed $testPath + * @param mixed $run + * @param mixed $fv + * @param mixed $rv + */ + function loadPageRunData($testPath, $run, $cached, $options = null, $allEvents = false) + { + $ret = null; - if( $cached ) - $ret = loadPageData("$testPath/{$run}_Cached_IEWPG.txt", $options); - else - $ret = loadPageData("$testPath/{$run}_IEWPG.txt", $options); - if (!isset($ret) || !is_array($ret) || !count($ret)) - GetDevToolsRequests($testPath, $run, $cached, $requests, $ret); - - // see if we have video files to calculate a visually complete time from - $basic_results = false; - if (array_key_exists('basic', $_REQUEST) && $_REQUEST['basic']) - $basic_results = true; - if (isset($ret) && !$basic_results) { - loadUserTimingData($ret, $testPath, $run, $cached); - if (array_key_exists('loadTime', $ret) && - !$ret['loadTime'] && - array_key_exists('fullyLoaded', $ret) && - $ret['fullyLoaded'] > 0) - $ret['loadTime'] = $ret['fullyLoaded']; - $video_dir = "$testPath/video_$run"; - if ($cached) - $video_dir .= '_cached'; - if( is_dir($video_dir) && (!array_key_exists('lastVisualChange', $ret) || !$ret['lastVisualChange'])) { - $frames = null; - loadVideo($video_dir, $frames); - if( isset($frames) && is_array($frames) && count($frames) ) { - end($frames); - $last = key($frames); - reset($frames); - if( $last ) { - $ret['lastVisualChange'] = $last * 100; - if (!array_key_exists('visualComplete', $ret)) - $ret['visualComplete'] = $ret['lastVisualChange']; - } - } - } - require_once('./video/visualProgress.inc.php'); - $startOffset = array_key_exists('testStartOffset', $ret) ? intval(round($ret['testStartOffset'])) : 0; - $progress = GetVisualProgress($testPath, $run, $cached, null, null, $startOffset); - if (isset($progress) && is_array($progress)) { - if (array_key_exists('SpeedIndex', $progress)) - $ret['SpeedIndex'] = $progress['SpeedIndex']; - if (array_key_exists('visualComplete', $progress)) - $ret['visualComplete'] = $progress['visualComplete']; - if (array_key_exists('startRender', $progress) && (!array_key_exists('render', $ret) || !$ret['render'])) - $ret['render'] = $progress['startRender']; - if (array_key_exists('DevTools', $progress) && is_array($progress['DevTools'])) { - if (array_key_exists('SpeedIndex', $progress['DevTools'])) { - $ret['SpeedIndexDT'] = intval($progress['DevTools']['SpeedIndex']); - if (!array_key_exists('SpeedIndex', $ret)) - $ret['SpeedIndex'] = $ret['SpeedIndexDT']; - } - if (array_key_exists('VisuallyComplete', $progress['DevTools'])) { - $ret['VisuallyCompleteDT'] = $progress['DevTools']['VisuallyComplete']; - if (!array_key_exists('visualComplete', $ret)) - $ret['visualComplete'] = $ret['VisuallyCompleteDT']; - } - if (array_key_exists('StartRender', $progress['DevTools'])) { - $ret['renderDT'] = $progress['DevTools']['StartRender']; - if (!array_key_exists('render', $ret) || !$ret['render']) - $ret['render'] = $ret['renderDT']; - } - } - if ((!array_key_exists('lastVisualChange', $ret) || - !$ret['lastVisualChange']) && - array_key_exists('visualComplete', $ret)) - $ret['lastVisualChange'] = $ret['visualComplete']; - } - // see if we need a custom Speed Index as well - $end = null; - if (isset($options) && array_key_exists('end', $options)) { - $end = $options['end']; - $progress = GetVisualProgress($testPath, $run, $cached, null, $end, $startOffset); - if (isset($progress) && is_array($progress)) { - if (array_key_exists('SpeedIndex', $progress)) - $ret['SpeedIndexCustom'] = $progress['SpeedIndex']; - $ret['visualCompleteCustom'] = $progress['visualComplete']; - } - } - } + if( $cached ) + $ret = loadPageData("$testPath/{$run}_Cached_IEWPG.txt", $testPath, $options, $allEvents); + else + $ret = loadPageData("$testPath/{$run}_IEWPG.txt", $testPath, $options, $allEvents); + if (!isset($ret) || !is_array($ret) || !count($ret)) + GetDevToolsRequests($testPath, $run, $cached, $requests, $ret); - if (isset($ret)) { - // clean up any insane values (from negative numbes as unsigned most likely) - $times = array('loadTime', - 'TTFB', - 'render', - 'fullyLoaded', - 'docTime', - 'domTime', - 'aft', - 'titleTime', - 'loadEventStart', - 'loadEventEnd', - 'domContentLoadedEventStart', - 'domContentLoadedEventEnd', - 'lastVisualChange', - 'server_rtt', - 'firstPaint'); - foreach ($times as $key) { - if (!array_key_exists($key, $ret) || - $ret[$key] > 3600000 || - $ret[$key] < 0) - $ret[$key] = 0; - } - } - - return $ret; -} + // TODO adapt for multiple steps (same data for every step used) + foreach($ret as $eventName => $data){ + // see if we have video files to calculate a visually complete time from + if (isset($data)) { + $video_dir = "$testPath/video_$run"; + if ($cached) + $video_dir .= '_cached'; + if( is_dir($video_dir) && (!array_key_exists('lastVisualChange', $data) || !$data['lastVisualChange'])) { + $frames = null; + loadVideo($video_dir, $frames); + if( isset($frames) && is_array($frames) && count($frames) ) { + end($frames); + $last = key($frames); + reset($frames); + if( $last ) { + $data['lastVisualChange'] = $last * 100; + if (!array_key_exists('visualComplete', $data)) + $data['visualComplete'] = $data['lastVisualChange']; + } + } + } + require_once('./video/visualProgress.inc.php'); + $progress = GetVisualProgress($testPath, $run, $cached); + if (isset($progress) && is_array($progress)) { + if (array_key_exists('SpeedIndex', $progress)) { + $data['SpeedIndex'] = $progress['SpeedIndex']; + } + if (array_key_exists('visualComplete', $progress)) { + $data['visualComplete'] = $progress['visualComplete']; + } + if (array_key_exists('DevTools', $progress) && is_array($progress['DevTools'])) { + if (array_key_exists('SpeedIndex', $progress['DevTools'])) { + $data['SpeedIndexDT'] = intval($progress['DevTools']['SpeedIndex']); + if (!array_key_exists('SpeedIndex', $data)) + $data['SpeedIndex'] = $data['SpeedIndexDT']; + } + if (array_key_exists('VisuallyComplete', $progress['DevTools'])) { + $data['VisuallyCompleteDT'] = $progress['DevTools']['VisuallyComplete']; + if (!array_key_exists('visualComplete', $data)) + $data['visualComplete'] = $data['VisuallyCompleteDT']; + } + if (array_key_exists('StartRender', $progress['DevTools']) && + (!array_key_exists('render', $data) || !$data['render'])) + $data['render'] = $progress['DevTools']['StartRender']; + } + if ((!array_key_exists('lastVisualChange', $data) || + !$data['lastVisualChange']) && + array_key_exists('visualComplete', $data)) + $data['lastVisualChange'] = $data['visualComplete']; + } + // see if we need a custom Speed Index as well + $end = null; + if (isset($options) && array_key_exists('end', $options)) { + $end = $options['end']; + $progress = GetVisualProgress($testPath, $run, $cached, null, $end); + if (isset($progress) && is_array($progress)) { + if (array_key_exists('FLI', $progress)) { + $data['SpeedIndexCustom'] = $progress['FLI']; + } + $data['visualCompleteCustom'] = $progress['visualComplete']; + } + } + } + $ret[$eventName] = $data; + } + return $ret; + } -/** -* Load the page data from the specified file -* -* @param mixed $file -*/ -function loadPageData($file, $options = null) -{ - $ret = null; - $lines = gz_file($file); - if( $lines) - { - // loop through each line in the file until we get a data record - foreach($lines as $linenum => $line) - { - $parseLine = str_replace("\t", "\t ", $line); - $fields = explode("\t", $parseLine); - if( count($fields) > 34 && trim($fields[0]) != 'Date' ) - { - $ret = array(); - $ret = array( 'URL' => @htmlspecialchars(trim($fields[3])), - // 'loadTime' => (int)$fields[4], - 'loadTime' => @(int)$fields[32], - 'TTFB' => @(int)$fields[5], - 'bytesOut' => @(int)$fields[7], - 'bytesOutDoc' => @(int)$fields[45], - 'bytesIn' => @(int)$fields[8], - 'bytesInDoc' => @(int)$fields[46], - 'connections' => @(int)$fields[10], - 'requests' => @(int)$fields[11], - 'requestsDoc' => @(int)$fields[49], - 'responses_200' => @(int)$fields[12], - 'responses_404' => @(int)$fields[15], - 'responses_other' => @(int)$fields[16], - 'result' => @(int)$fields[17], - 'render' => @(int)$fields[18], - 'fullyLoaded' => @(int)$fields[22], - 'cached' => @(int)$fields[27], - 'docTime' => @(int)$fields[32], - 'domTime' => @(int)$fields[34], - 'score_cache' => @(int)$fields[36], - 'score_cdn' => @(int)$fields[37], - 'score_gzip' => @(int)$fields[39], - 'score_cookies' => @(int)$fields[40], - 'score_keep-alive' => @(int)$fields[41], - 'score_minify' => @(int)$fields[43], - 'score_combine' => @(int)$fields[44], - 'score_compress' => @(int)$fields[55], - 'score_etags' => @(int)$fields[58], - 'gzip_total' => @(int)$fields[64], - 'gzip_savings' => @(int)$fields[65], - 'minify_total' => @(int)$fields[66], - 'minify_savings' => @(int)$fields[67], - 'image_total' => @(int)$fields[68], - 'image_savings' => @(int)$fields[69], - 'optimization_checked' => @(int)$fields[71], - 'aft' => @(int)$fields[72], - 'domElements' => @(int)$fields[73], - 'pageSpeedVersion' => @trim($fields[74]), - 'title' => @htmlspecialchars(trim($fields[75]),ENT_NOQUOTES,'UTF-8'), - 'titleTime' => @(int)$fields[76], - 'loadEventStart' => @(int)$fields[77], - 'loadEventEnd' => @(int)$fields[78], - 'domContentLoadedEventStart' => @(int)$fields[79], - 'domContentLoadedEventEnd' => @(int)$fields[80], - 'lastVisualChange' => @(int)$fields[81], - 'browser_name' => @trim($fields[82]), - 'browser_version' => @trim($fields[83]), - 'server_count' => @(int)trim($fields[84]), - 'server_rtt' => @(int)trim($fields[85]), - 'base_page_cdn' => @trim($fields[86]), - 'adult_site' => @(int)trim($fields[87]) - ); - - $ret['fixed_viewport'] = (array_key_exists(88, $fields) && strlen(trim($fields[88]))) ? (int)trim($fields[88]) : -1; - $ret['score_progressive_jpeg'] = (array_key_exists(89, $fields) && strlen(trim($fields[89]))) ? (int)trim($fields[89]) : -1; - $ret['firstPaint'] = (array_key_exists(90, $fields) && strlen(trim($fields[90]))) ? (int)trim($fields[90]) : 0; - //$ret['peakMem'] = (array_key_exists(91, $fields) && strlen(trim($fields[91]))) ? (int)trim($fields[91]) : 0; - //$ret['processCount'] = (array_key_exists(92, $fields) && strlen(trim($fields[92]))) ? (int)trim($fields[92]) : 0; - $ret['docCPUms'] = (array_key_exists(93, $fields) && strlen(trim($fields[93]))) ? floatval(trim($fields[93])) : 0.0; - $ret['fullyLoadedCPUms'] = (array_key_exists(94, $fields) && strlen(trim($fields[94]))) ? floatval(trim($fields[94])) : 0.0; - $ret['docCPUpct'] = (array_key_exists(95, $fields) && strlen(trim($fields[95]))) ? floatval(trim($fields[95])) : 0; - $ret['fullyLoadedCPUpct'] = (array_key_exists(96, $fields) && strlen(trim($fields[96]))) ? floatval(trim($fields[96])) : 0; - - $ret['date'] = strtotime(trim($fields[0]) . ' ' . trim($fields[1])); - if (!strlen($ret['pageSpeedVersion'])) - $ret['pageSpeedVersion'] = '1.9'; - - break; - } - } - } - - return $ret; -} + /** + * Load the page data from the specified file + * + * @param mixed $file + */ + function loadPageData($file, $testPath, $options = null, $allEvents = false) + { + if( gz_is_file("$testPath/testinfo.json") ) + $test_info = json_decode(gz_file_get_contents("$testPath/testinfo.json"), true); + $ret = null; + $lines = gz_file($file); + if( $lines) + { + $ret = array(); + $pageNumber = 1; + // loop through each line in the file until we get a data record + foreach($lines as $linenum => $line) + { + $parseLine = str_replace("\t", "\t ", $line); + $fields = explode("\t", $parseLine); + $eventName = getFullEventName($test_info['label'], trim($fields[2]), $linenum, $ret); + + if( count($fields) > 34 && trim($fields[0]) != 'Date' ) + { + $ret[$eventName] = array(); + $ret[$eventName] = array( 'URL' => @htmlspecialchars(trim($fields[3])), + // 'loadTime' => (int)$fields[4], + 'loadTime' => @(int)$fields[32], + 'TTFB' => @(int)$fields[5], + 'bytesOut' => @(int)$fields[7], + 'bytesOutDoc' => @(int)$fields[45], + 'bytesIn' => @(int)$fields[8], + 'bytesInDoc' => @(int)$fields[46], + 'connections' => @(int)$fields[10], + 'requests' => @(int)$fields[11], + 'requestsDoc' => @(int)$fields[49], + 'responses_200' => @(int)$fields[12], + 'responses_404' => @(int)$fields[15], + 'responses_other' => @(int)$fields[16], + 'result' => @(int)$fields[17], + 'render' => @(int)$fields[18], + 'fullyLoaded' => @(int)$fields[22], + 'cached' => @(int)$fields[27], + 'docTime' => @(int)$fields[32], + 'domTime' => @(int)$fields[34], + 'score_cache' => @(int)$fields[36], + 'score_cdn' => @(int)$fields[37], + 'score_gzip' => @(int)$fields[39], + 'score_cookies' => @(int)$fields[40], + 'score_keep-alive' => @(int)$fields[41], + 'score_minify' => @(int)$fields[43], + 'score_combine' => @(int)$fields[44], + 'score_compress' => @(int)$fields[55], + 'score_etags' => @(int)$fields[58], + 'gzip_total' => @(int)$fields[64], + 'gzip_savings' => @(int)$fields[65], + 'minify_total' => @(int)$fields[66], + 'minify_savings' => @(int)$fields[67], + 'image_total' => @(int)$fields[68], + 'image_savings' => @(int)$fields[69], + 'optimization_checked' => @(int)$fields[71], + 'aft' => @(int)$fields[72], + 'domElements' => @(int)$fields[73], + 'pageSpeedVersion' => @trim($fields[74]), + 'title' => @htmlspecialchars(trim($fields[75]),ENT_NOQUOTES,'UTF-8'), + 'titleTime' => @(int)$fields[76], + 'loadEventStart' => @(int)$fields[77], + 'loadEventEnd' => @(int)$fields[78], + 'domContentLoadedEventStart' => @(int)$fields[79], + 'domContentLoadedEventEnd' => @(int)$fields[80], + 'lastVisualChange' => @(int)$fields[81], + 'browser_name' => @trim($fields[82]), + 'browser_version' => @trim($fields[83]), + 'server_count' => @(int)trim($fields[84]), + 'server_rtt' => @(int)trim($fields[85]), + 'base_page_cdn' => @trim($fields[86]), + 'adult_site' => @(int)trim($fields[87]) + ); -/** -* Find the median run and use it for the results -* -* @param mixed $pageData -*/ -function calculatePageStats(&$pageData, &$fv, &$rv) -{ - $fvCount = 0; - $rvCount = 0; - - // calculate the averages - if( count($pageData) ) { - foreach( $pageData as $run => $data ) { - if( isset($data[0]) && $data[0]['cached'] === 0 ) { - if (!isset($metrics)) { - $metrics = array(); - foreach ($data[0] as $metric => $value) - $metrics[] = $metric; - } - // only look at non-error runs - if( $data[0]['result'] === 0 || $data[0]['result'] === 99999 ) - { - if( !isset($fv) ) - $fv = array(); - foreach ($metrics as $metric) { - if (array_key_exists($metric, $fv)) - $fv[$metric] += $data[0][$metric]; - else - $fv[$metric] = $data[0][$metric]; - } - $fvCount++; - } - } - - if( isset($data[1]) && $data[1]['cached'] ) - { - if (!isset($metrics)) { - $metrics = array(); - foreach ($data[0] as $metric => $value) - $metrics[] = $metric; - } - // only look at non-error runs - if( $data[1]['result'] === 0 || $data[1]['result'] === 99999 ) - { - if( !isset($rv) ) - $rv = array(); - foreach ($metrics as $metric) { - if (array_key_exists($metric, $rv)) - $rv[$metric] += $data[1][$metric]; - else - $rv[$metric] = $data[1][$metric]; - } - $rvCount++; - } - } - } - } + $ret[$eventName]['fixed_viewport'] = (array_key_exists(88, $fields) && strlen(trim($fields[88]))) ? (int)trim($fields[88]) : -1; + $ret[$eventName]['score_progressive_jpeg'] = (array_key_exists(89, $fields) && strlen(trim($fields[89]))) ? (int)trim($fields[89]) : -1; + $ret[$eventName]['firstPaint'] = (array_key_exists(90, $fields) && strlen(trim($fields[90]))) ? (int)trim($fields[90]) : 0; + //$ret[$eventName]['peakMem'] = (array_key_exists(91, $fields) && strlen(trim($fields[91]))) ? (int)trim($fields[91]) : 0; + //$ret[$eventName]['processCount'] = (array_key_exists(92, $fields) && strlen(trim($fields[92]))) ? (int)trim($fields[92]) : 0; + $ret[$eventName]['docCPUms'] = (array_key_exists(93, $fields) && strlen(trim($fields[93]))) ? floatval(trim($fields[93])) : 0.0; + $ret[$eventName]['fullyLoadedCPUms'] = (array_key_exists(94, $fields) && strlen(trim($fields[94]))) ? floatval(trim($fields[94])) : 0.0; + $ret[$eventName]['docCPUpct'] = (array_key_exists(95, $fields) && strlen(trim($fields[95]))) ? floatval(trim($fields[95])) : 0; + $ret[$eventName]['fullyLoadedCPUpct'] = (array_key_exists(96, $fields) && strlen(trim($fields[96]))) ? floatval(trim($fields[96])) : 0; - // calculate the first view stats - if( isset($fv) && isset($metrics) && $fvCount > 0 ) - { - foreach ($metrics as $metric) - $fv[$metric] /= (double)$fvCount; - - // go through and find the run closest to the average - $closest = -1; - $distance = 10000000000; - - foreach( $pageData as $run => $data ) - { - if( isset($data[0]) && ($data[0]['result'] === 0 || $data[0]['result'] === 99999) ) - { - $curDist = abs($data[0]['loadTime'] - $fv['loadTime']); - if( $curDist < $distance ) - { - $closest = $run; - $distance = $curDist; - } - } - } - - if( $closest != -1 ) - $fv['avgRun'] = $closest; - } + if(!isset($ret[$eventName]['pageNumber'])){ + $ret[$eventName]['pageNumber'] = $pageNumber++; + } - // calculate the repeat view stats - if( isset($rv) && isset($metrics) && $rvCount > 0 ) - { - foreach ($metrics as $metric) - $rv[$metric] /= (double)$rvCount; - - // go through and find the run closest to the average - $closest = -1; - $distance = 10000000000; - - foreach( $pageData as $run => $data ) - { - if( isset($data[1]) && ($data[1]['result'] === 0 || $data[1]['result'] === 99999) ) - { - $curDist = abs($data[1]['loadTime'] - $rv['loadTime']); - if( $curDist < $distance ) - { - $closest = $run; - $distance = $curDist; - } - } - } - - if( $closest != -1 ) - $rv['avgRun'] = $closest; - } + $ret[$eventName]['date'] = strtotime(trim($fields[0]) . ' ' . trim($fields[1])); + if (!strlen($ret[$eventName]['pageSpeedVersion'])){ + $ret[$eventName]['pageSpeedVersion'] = '1.9'; + } + if(!$allEvents){ + break; + } + } + } + } + if(!$allEvents){ + return $ret[array_keys($ret)[0]]; + } + return $ret; } -/** -* Find the test run closest to the median -* -* @param mixed $pageData -* @param mixed $cached -*/ -function GetMedianRun(&$pageData, $cached, $metric = 'loadTime') { - $run = 0; - $cached = $cached ? 1:0; - $times = array(); - - // try successful-only runs first - foreach( $pageData as $index => &$pageRun ) { - if( array_key_exists($cached, $pageRun) && - array_key_exists('result', $pageRun[$cached]) && - array_key_exists($metric, $pageRun[$cached]) && - ($pageRun[$cached]['result'] == 0 || $pageRun[$cached]['result'] == 99999) ) { - $times[$index] = $pageRun[$cached][$metric]; - } - } - - if (!count($times)) { - // include error runs - foreach( $pageData as $index => &$pageRun ) { - if( array_key_exists($cached, $pageRun) && array_key_exists($metric, $pageRun[$cached])) { - $times[$index] = $pageRun[$cached][$metric]; - } - } - } - - $count = count($times); - if( $count > 1 ) { - asort($times); - if (array_key_exists('medianRun', $_REQUEST) && - $_REQUEST['medianRun'] == 'fastest') - $medianIndex = 1; - else - $medianIndex = (int)floor(((float)$count + 1.0) / 2.0); - $current = 0; - foreach( $times as $index => $time ) { - $current++; - if( $current == $medianIndex ) { - $run = $index; - break; - } - } - } - elseif( $count == 1 ) { - foreach( $times as $index => $time ) { - $run = $index; - break; - } - } - - // fall back to loadTime if we failed to get a run with the specified metric - if (!$run && $metric != 'loadTime') { - $run = GetMedianRun($pageData, $cached); - } - - return $run; -} + /** + * Find the median run and use it for the results + * + * @param mixed $pageData + */ + function calculatePageStats(&$pageData, &$fv, &$rv) + { + $fvCount = 0; + $rvCount = 0; -/** -* Count the number of tests with successful results -* -* @param mixed $pageData -* @param mixed $cached -*/ -function CountSuccessfulTests(&$pageData, $cached) -{ - $count = 0; - foreach( $pageData as &$run ) - { - if( $run[$cached]['result'] === 0 || $run[$cached]['result'] === 99999 ) - $count++; - } - - return $count; -} + // calculate the averages + if( count($pageData) ) { + foreach( $pageData as $run => $data ) { + if( isset($data[0]) && $data[0]['cached'] === 0 ) { + if (!isset($metrics)) { + $metrics = array(); + foreach ($data[0] as $metric => $value) + $metrics[] = $metric; + } + // only look at non-error runs + if( $data[0]['result'] === 0 || $data[0]['result'] === 99999 ) + { + if( !isset($fv) ) + $fv = array(); + foreach ($metrics as $metric) { + if (array_key_exists($metric, $fv)) + $fv[$metric] += $data[0][$metric]; + else + $fv[$metric] = $data[0][$metric]; + } + $fvCount++; + } + } -/** -* Calculate some stats for the given metric from the page data -* -* @param mixed $pageData -* @param mixed $cached -* @param mixed $metric -* @param mixed $median -* @param mixed $avg -* @param mixed $stdDev -*/ -function CalculateAggregateStats(&$pageData, $cached, $metric, &$median, &$avg, &$stdDev) -{ - $median = null; - $avg = null; - $stdDev = null; - $count = 0; - - // first pass, calculate the average and array of values for grabbing the median - $values = array(); - $sum = 0; - foreach( $pageData as &$run ) { - if( ($run[$cached]['result'] === 0 || $run[$cached]['result'] === 99999) && array_key_exists($metric, $run[$cached]) ) { - $values[] = $run[$cached][$metric]; - $sum += $run[$cached][$metric]; + if( isset($data[1]) && $data[1]['cached'] ) + { + if (!isset($metrics)) { + $metrics = array(); + foreach ($data[0] as $metric => $value) + $metrics[] = $metric; + } + // only look at non-error runs + if( $data[1]['result'] === 0 || $data[1]['result'] === 99999 ) + { + if( !isset($rv) ) + $rv = array(); + foreach ($metrics as $metric) { + if (array_key_exists($metric, $rv)) + $rv[$metric] += $data[1][$metric]; + else + $rv[$metric] = $data[1][$metric]; + } + $rvCount++; + } + } + } + } + + // calculate the first view stats + if( isset($fv) && isset($metrics) && $fvCount > 0 ) + { + foreach ($metrics as $metric) + $fv[$metric] /= (double)$fvCount; + + // go through and find the run closest to the average + $closest = -1; + $distance = 10000000000; + + foreach( $pageData as $run => $data ) + { + if( isset($data[0]) && ($data[0]['result'] === 0 || $data[0]['result'] === 99999) ) + { + $curDist = abs($data[0]['loadTime'] - $fv['loadTime']); + if( $curDist < $distance ) + { + $closest = $run; + $distance = $curDist; + } + } + } + + if( $closest != -1 ) + $fv['avgRun'] = $closest; + } + + // calculate the repeat view stats + if( isset($rv) && isset($metrics) && $rvCount > 0 ) + { + foreach ($metrics as $metric) + $rv[$metric] /= (double)$rvCount; + + // go through and find the run closest to the average + $closest = -1; + $distance = 10000000000; + + foreach( $pageData as $run => $data ) + { + if( isset($data[1]) && ($data[1]['result'] === 0 || $data[1]['result'] === 99999) ) + { + $curDist = abs($data[1]['loadTime'] - $rv['loadTime']); + if( $curDist < $distance ) + { + $closest = $run; + $distance = $curDist; + } + } + } + + if( $closest != -1 ) + $rv['avgRun'] = $closest; + } + } + + /** + * Find the test run closest to the median + * + * @param mixed $pageData + * @param mixed $cached + */ + function GetMedianRun(&$pageData, $cached, $metric = 'loadTime') { + $run = 0; + $cached = $cached ? 1:0; + $times = array(); + + // try successful-only runs first + foreach( $pageData as $index => &$pageRun ) { + if( array_key_exists($cached, $pageRun) && + array_key_exists('result', $pageRun[$cached]) && + array_key_exists($metric, $pageRun[$cached]) && + ($pageRun[$cached]['result'] == 0 || $pageRun[$cached]['result'] == 99999) ) { + $times[$index] = $pageRun[$cached][$metric]; + } + } + + if (!count($times)) { + // include error runs + foreach( $pageData as $index => &$pageRun ) { + if( array_key_exists($cached, $pageRun) && array_key_exists($metric, $pageRun[$cached])) { + $times[$index] = $pageRun[$cached][$metric]; + } + } + } + + $count = count($times); + if( $count > 1 ) { + asort($times); + if (array_key_exists('medianRun', $_REQUEST) && + $_REQUEST['medianRun'] == 'fastest') + $medianIndex = 1; + else + $medianIndex = (int)floor(((float)$count + 1.0) / 2.0); + $current = 0; + foreach( $times as $index => $time ) { + $current++; + if( $current == $medianIndex ) { + $run = $index; + break; + } + } + } + elseif( $count == 1 ) { + foreach( $times as $index => $time ) { + $run = $index; + break; + } + } + + // fall back to loadTime if we failed to get a run with the specified metric + if (!$run && $metric != 'loadTime') { + $run = GetMedianRun($pageData, $cached); + } + + return $run; + } + + /** + * Count the number of tests with successful results + * + * @param mixed $pageData + * @param mixed $cached + */ + function CountSuccessfulTests(&$pageData, $cached) + { + $count = 0; + foreach( $pageData as &$run ) + { + if( $run[$cached]['result'] === 0 || $run[$cached]['result'] === 99999 ) + $count++; + } + + return $count; + } + + /** + * Calculate some stats for the given metric from the page data + * + * @param mixed $pageData + * @param mixed $cached + * @param mixed $metric + * @param mixed $median + * @param mixed $avg + * @param mixed $stdDev + */ + function CalculateAggregateStats(&$pageData, $cached, $metric, &$median, &$avg, &$stdDev) + { + $median = null; + $avg = null; + $stdDev = null; + $count = 0; + + // first pass, calculate the average and array of values for grabbing the median + $values = array(); + $sum = 0; + foreach( $pageData as &$run ) { + if( ($run[$cached]['result'] === 0 || $run[$cached]['result'] === 99999) && array_key_exists($metric, $run[$cached]) ) { + $values[] = $run[$cached][$metric]; + $sum += $run[$cached][$metric]; $count++; } } - + if( $count ) { $avg = $sum / $count; sort($values, SORT_NUMERIC); $medianIndex = (int)($count / 2); $median = $values[$medianIndex]; - + // pass 2, calculate the standard deviation $sum = 0; foreach($values as $value){ @@ -488,7 +484,7 @@ function CalculateAggregateStats(&$pageData, $cached, $metric, &$median, &$avg, } $stdDev = sqrt($sum / $count); } - + return $count; } diff --git a/www/pageimages.php b/www/pageimages.php index 71521e3095..9e6c47103b 100644 --- a/www/pageimages.php +++ b/www/pageimages.php @@ -4,7 +4,8 @@ require_once('page_data.inc'); $secure = false; $haveLocations = false; -$requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, true); +$eventName = urldecode($_GET['eventName']); +$requests = getRequests($id, $testPath, $run, $_GET["cached"], $secure, $haveLocations, true, false, true); $page_keywords = array('Images','Webpagetest','Website Speed Test','Page Speed'); $page_description = "Website speed test images$testLabel."; $userImages = true; @@ -33,7 +34,7 @@

Images are what are currently being served from the given url and may not necessarily match what was loaded at the time of the test.

First Byte Time
colspan=1>First Byte Time Applicable Objects Time to First Byte for the page (back-end processing + redirects)
Keep-Alive
colspan=1>Keep-Alive Applicable Objects All objects that are from a domain that serves more than one object for the page (i.e. if only a single object is served from a given domain it will not be checked)
GZIP Text
colspan=1>GZIP Text Applicable Objects All objects with a mime type of "text/*" or "*javascript*"
Use Progressive JPEGs
colspan=1>Use Progressive JPEGs Applicable Objects All JPEG Images
Cache Static
colspan=1>Cache Static Applicable Objects Any non-html object with a mime type of "text/*", "*javascript*" or "image/*" that does not explicitly have an Expires header of 0 or -1, a cache-control header of "private", @@ -541,7 +549,7 @@ function dumpOptimizationGlossary(&$settings)
Use A CDN
colspan=1>Use A CDN Applicable Objects All static non-html content (css, js and images)
+
+

+ +

+
+
-

Full Optimization Checklist

- + +

Full Optimization Checklist -

+ '; + ?> +


+ -


- -

Details:

+ + +

Details (for all Event Names):

- - WebPagetest Test Result<?php echo $testLabel; ?> - - - - - - - -
- -
- -

-
- + + + + + +

+ +
+ +

+
+ \n"; } else { echo "Url: $url
\n"; } echo "From: {$test['test']['location']}
\n"; echo GetTestInfoHtml(); - ?> -

- Test is partially complete ($available of $expected tests).
This page will refresh as tests complete."; - echo "\n"; - } - else - { - ?> -
-
- +

+ Test is partially complete ($available of $expected tests).
This page will refresh as tests complete."; + echo "\n"; + } + else + { + ?> +
+
+ '; - echo "\n\n"; - echo "\n"; - if( strlen($secret) ){ + echo '
'; + echo "\n\n"; + echo "\n"; + if( strlen($secret) ){ $hashStr = $secret; $hashStr .= $_SERVER['HTTP_USER_AGENT']; $hashStr .= $owner; - + $now = gmdate('c'); echo "\n"; $hashStr .= $now; - + $hmac = sha1($hashStr); echo "\n"; } @@ -116,223 +121,275 @@ $page_description = "Website performance test result$testLabel."; echo "\n\n"; } ?> -
- Raw page data - "; - echo "Raw object data"; - } - else - { - echo "Raw page data - "; - echo "Raw object data"; - } - echo '
Export HTTP Archive (.har)'; - if( array_key_exists('showslow', $test['testinfo']) && $test['testinfo']['showslow'] && strlen($settings['showslow']) ) - echo '
See in ShowSlow'; - if( is_dir('./google') && array_key_exists('enable_google_csi', $settings) && $settings['enable_google_csi'] ) - echo '
View CSI data'; - if( array_key_exists('publishTo', $settings) && $settings['publishTo'] ) - echo "
Publish to {$settings['publishTo']}"; - ?> -
-
-
- + Raw page data - "; + echo "Raw object data"; + } + else + { + echo "Raw page data - "; + echo "Raw object data"; + } + echo '
Export HTTP Archive (.har)'; + if( array_key_exists('showslow', $test['testinfo']) && $test['testinfo']['showslow'] && strlen($settings['showslow']) ) + echo '
See in ShowSlow'; + if( is_dir('./google') && array_key_exists('enable_google_csi', $settings) && $settings['enable_google_csi'] ) + echo '
View CSI data'; + if( array_key_exists('publishTo', $settings) && $settings['publishTo'] ) + echo "
Publish to {$settings['publishTo']}"; + ?> +
+
+
+ 1) - echo '

Performance Results (Median Run)

'; - ?> -
- - 0.0) - $cols++; - if (array_key_exists('domTime', $pageData[$fvMedian][0]) && (float)$pageData[$fvMedian][0]['domTime'] > 0.0) - $cols++; - if (array_key_exists('domElements', $pageData[$fvMedian][0]) && $pageData[$fvMedian][0]['domElements'] > 0) - $cols++; - if((array_key_exists('SpeedIndex', $pageData[$fvMedian][0]) && (int)$pageData[$fvMedian][0]['SpeedIndex'] > 0) || - (array_key_exists('SpeedIndexDT', $pageData[$fvMedian][0]) && (int)$pageData[$fvMedian][0]['SpeedIndexDT'] > 0)) + + foreach($pageDataArray as $eventName => $pageData){ + $medianRun = GetMedianRun($pageData, 0, $median_metric); + if($medianRun != 0){ + $fvMedianArray[$eventName] = $medianRun; + } + $medianRun = GetMedianRun($pageData, 1, $median_metric); + if($medianRun != 0){ + $rvMedianArray[$eventName] = $medianRun; + } + } + if( !empty($fvMedianArray) && !$is_test_error ) + { + if( count($pageData) > 1) + echo '

Performance Results (Median Runs per page)

'; + ?> +
+ + ', 0.0, "float", -1, $fvMedian, 0)) + $cols++; + if (checkForAllEventNames($pageDataArray, 'domElements', '>', 0, null, -1, $fvMedian, 0)) + $cols++; + if( checkForAllEventNames($pageDataArray, 'SpeedIndex', '>', 0, "int", -1, $fvMedian, 0) || + checkForAllEventNames($pageDataArray, 'SpeedIndexDT', '>', 0, "int", -1, $fvMedian, 0)) $cols++; ?> - - \n"; - ?> - - - - - - - - - 0.0) { ?> - - - 0) || - (array_key_exists('SpeedIndexDT', $pageData[$fvMedian][0]) && (int)$pageData[$fvMedian][0]['SpeedIndexDT'] > 0)){ ?> - - - 0.0) { ?> - - - 0) { ?> - - + + \n"; + ?> + + + + + + + + + ', 0, "int", -1, $fvMedian, 0) || + checkForAllEventNames($pageDataArray, 'SpeedIndexDT', '>', 0, "int", -1, $fvMedian, 0)) {?> + + + ', 0.0, "float", -1, $fvMedian, 0)) { ?> + + + ', 0, null, -1, $fvMedian, 0)) { ?> + + - - - + + + - - - - - - \n"; - echo "\n"; - echo "\n"; - if(array_key_exists('userTime', $pageData[$fvMedian][0]) && (float)$pageData[$fvMedian][0]['userTime'] > 0.0) - echo "\n"; - if(array_key_exists('SpeedIndex', $pageData[$fvMedian][0]) && (int)$pageData[$fvMedian][0]['SpeedIndex'] > 0) { + + + + + $pageData){ + $fvMedian = $fvMedianArray[$eventName]; + ?> + + \n"; + echo "\n"; + echo "\n"; + if(checkForAllEventNames($pageDataArray, 'SpeedIndex', '>', 0, "int", -1, $fvMedian, 0)) { if(array_key_exists('SpeedIndexCustom', $pageData[$fvMedian][0])) - echo "\n"; + echo "\n"; else - echo "\n"; - } elseif(array_key_exists('SpeedIndexDT', $pageData[$fvMedian][0]) && (int)$pageData[$fvMedian][0]['SpeedIndexDT'] > 0) { + echo "\n"; + } elseif(checkForAllEventNames($pageDataArray, 'SpeedIndexDT', '>', 0, "int", -1, $fvMedian, 0)) { echo "\n"; } - if(array_key_exists('domTime', $pageData[$fvMedian][0]) && (float)$pageData[$fvMedian][0]['domTime'] > 0.0) - echo "\n"; - if(array_key_exists('domElements', $pageData[$fvMedian][0]) && $pageData[$fvMedian][0]['domElements'] > 0) - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; + if (checkForAllEventNames($pageDataArray, 'domTime', '>', 0.0, "float", -1, $fvMedian, 0)){ + $domTime = number_format($pageData[$fvMedian][0]['domTime'] / 1000.0, 3) . "s"; + if($domTime=="0.000s"){ + $domTime="-"; + } + echo "\n"; + } + if (checkForAllEventNames($pageDataArray, 'domElements', '>', 0, null, -1, $fvMedian, 0)){ + $domElems = $pageData[$fvMedian][0]['domElements']; + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - ?> - - - - \n"; - echo "\n"; - echo "\n"; - if(array_key_exists('userTime', $pageData[$fvMedian][0]) && (float)$pageData[$fvMedian][0]['userTime'] > 0.0) - echo "\n"; - if(array_key_exists('SpeedIndex', $pageData[$fvMedian][0]) && (int)$pageData[$fvMedian][0]['SpeedIndex'] > 0) { + echo "\n"; + echo "\n"; + echo "\n"; + ?> + + + + + + + $pageData) + { + $rvMedian = $rvMedianArray[$eventName]; + ?> + + \n"; + echo "\n"; + echo "\n"; + if(array_key_exists('SpeedIndex', $pageData[$rvMedian][1])) { $disp = '-'; - if(array_key_exists('SpeedIndex', $pageData[$rvMedian][1]) && (int)$pageData[$rvMedian][1]['SpeedIndex'] > 0) - $disp = $pageData[$rvMedian][1]['SpeedIndex']; + if(checkForAllEventNames($pageDataArray, 'SpeedIndex', '>', 0, "int", -1, $rvMedian, 1)) + $disp = $pageData[$rvMedian][1]['SpeedIndex']; echo "\n"; - } elseif (array_key_exists('SpeedIndexDT', $pageData[$fvMedian][0]) && (int)$pageData[$fvMedian][0]['SpeedIndexDT'] > 0) { + } elseif (checkForAllEventNames($pageDataArray, 'SpeedIndexDT', '>', 0, "int", -1, $rvMedian, 1)) { $disp = '-'; if(array_key_exists('SpeedIndexDT', $pageData[$rvMedian][1]) && (int)$pageData[$rvMedian][1]['SpeedIndexDT'] > 0) - $disp = $pageData[$rvMedian][1]['SpeedIndexDT']; + $disp = $pageData[$rvMedian][1]['SpeedIndexDT']; echo "\n"; } - if(array_key_exists('domTime', $pageData[$fvMedian][0]) && (float)$pageData[$fvMedian][0]['domTime'] > 0.0) - echo "\n"; - if(array_key_exists('domElements', $pageData[$fvMedian][0]) && $pageData[$fvMedian][0]['domElements'] > 0) - echo "\n"; + if(checkForAllEventNames($pageDataArray, 'domTime', '>', 0.0, "float", -1, $rvMedian, 1)){ + $domTime = number_format($pageData[$rvMedian][1]['domTime'] / 1000.0, 3) . "s"; + if($domTime=="0.000s"){ + $domTime="-"; + } + echo "\n"; + } + if (checkForAllEventNames($pageDataArray, 'domElements', '>', 0, null, -1, $rvMedian, 1)){ + $domElems = $pageData[$rvMedian][1]['domElements']; + echo "\n"; + } - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - ?> - - -
Document CompleteFully Loaded
Load TimeFirst ByteStart RenderUser TimeSpeed IndexDOM ElementDOM ElementsDocument + CompleteFully + Loaded
Event Name (View)Load TimeFirst ByteStart RenderSpeed IndexDOM ElementDOM ElementsTimeRequestsBytes InTimeRequestsBytes InTimeRequestsBytes In
First View - 1) - echo " (Run $fvMedian)"; - echo "" . formatMsInterval($pageData[$fvMedian][0]['loadTime'], 3) . "" . formatMsInterval($pageData[$fvMedian][0]['TTFB'], 3) . "" . formatMsInterval($pageData[$fvMedian][0]['render'], 3) . "" . number_format($pageData[$fvMedian][0]['userTime'] / 1000.0, 3) . "sTimeRequestsBytes In
(First View) 1) + echo " (Run $fvMedian)"; + echo "" . formatMsInterval($pageData[$fvMedian][0]['loadTime'], 3) . "" . formatMsInterval($pageData[$fvMedian][0]['TTFB'], 3) . "" . formatMsInterval($pageData[$fvMedian][0]['render'], 3) . "{$pageData[$fvMedian][0]['SpeedIndexCustom']}{$pageData[$fvMedian][0]['SpeedIndexCustom']}{$pageData[$fvMedian][0]['SpeedIndex']}{$pageData[$fvMedian][0]['SpeedIndex']}{$pageData[$fvMedian][0]['SpeedIndexDT']}" . number_format($pageData[$fvMedian][0]['domTime'] / 1000.0, 3) . "s{$pageData[$fvMedian][0]['domElements']}" . formatMsInterval($pageData[$fvMedian][0]['docTime'], 3) . "" . number_format($pageData[$fvMedian][0]['requestsDoc'],0) . "" . number_format($pageData[$fvMedian][0]['bytesInDoc'] / 1024, 0) . " KB" . $domTime . "{$domElems}" . formatMsInterval($pageData[$fvMedian][0]['docTime'], 3) . "" . number_format($pageData[$fvMedian][0]['requestsDoc'],0) . "" . number_format($pageData[$fvMedian][0]['bytesInDoc'] / 1024, 0) . " KB" . formatMsInterval($pageData[$fvMedian][0]['fullyLoaded'], 3) . "" . number_format($pageData[$fvMedian][0]['requests'],0) . "" . number_format($pageData[$fvMedian][0]['bytesIn'] / 1024, 0) . " KB
Repeat View - 1) - echo " (Run $rvMedian)"; - echo "" . formatMsInterval($pageData[$rvMedian][1]['loadTime'], 3) . "" . formatMsInterval($pageData[$rvMedian][1]['TTFB'], 3) . "" . formatMsInterval($pageData[$rvMedian][1]['render'], 3) . "" . number_format($pageData[$rvMedian][1]['userTime'] / 1000.0, 3) . "s" . formatMsInterval($pageData[$fvMedian][0]['fullyLoaded'], 3) . "" . number_format($pageData[$fvMedian][0]['requests'],0) . "" . number_format($pageData[$fvMedian][0]['bytesIn'] / 1024, 0) . " KB
+ (Repeat View) 1) + echo " (Run $rvMedian)"; + echo "" . formatMsInterval($pageData[$rvMedian][1]['loadTime'], 3) . "" . formatMsInterval($pageData[$rvMedian][1]['TTFB'], 3) . "" . formatMsInterval($pageData[$rvMedian][1]['render'], 3) . "$disp$disp" . number_format($pageData[$rvMedian][1]['domTime'] / 1000.0, 3) . "s{$pageData[$rvMedian][1]['domElements']}" . $domTime . "{$domElems}" . formatMsInterval($pageData[$rvMedian][1]['docTime'], 3) . "" . number_format($pageData[$rvMedian][1]['requestsDoc'],0) . "" . number_format($pageData[$rvMedian][1]['bytesInDoc'] / 1024, 0) . " KB" . formatMsInterval($pageData[$rvMedian][1]['docTime'], 3) . "" . number_format($pageData[$rvMedian][1]['requestsDoc'],0) . "" . number_format($pageData[$rvMedian][1]['bytesInDoc'] / 1024, 0) . " KB" . formatMsInterval($pageData[$rvMedian][1]['fullyLoaded'], 3) . "" . number_format($pageData[$rvMedian][1]['requests'],0) . "" . number_format($pageData[$rvMedian][1]['bytesIn'] / 1024, 0) . " KB
- 1) { + echo "" . formatMsInterval($pageData[$rvMedian][1]['fullyLoaded'], 3) . "\n"; + echo "" . number_format($pageData[$rvMedian][1]['requests'],0) . "\n"; + echo "" . number_format($pageData[$rvMedian][1]['bytesIn'] / 1024, 0) . " KB\n"; + ?> + + + + +

+ 1) { echo "Plot Full Results"; } ?> -
- 1 ) - { - require_once('google/google_lib.inc'); - // Draw the table and print the first-view details. - $fv_params = ParseCsiInfo($id, $testPath, $fvMedian, false, true); - ?> -

Csi Metrics (Median Run)

- - - - ' . $csi_param . ''; - echo ''; - echo ''; + } + else + { + echo ''; + } + } + } + echo ''; ?> + +
First View'; - echo ' (Run ' . $fvMedian . ')'; - foreach ( $test['testinfo']['extract_csi'] as $csi_param ) - { +
+ 1 ) + { + require_once('google/google_lib.inc'); + // Draw the table and print the first-view details. + $fv_params = ParseCsiInfo($id, $testPath, $fvMedian, false, true); + ?> +

Csi Metrics (Median Run)

+ + + + ' . $csi_param . ''; + echo ''; + echo ''; + echo ''; } else { - echo ''; + echo ''; } - } - // Print the repeat view row. - if( $rvMedian ) - { + } + // Print the repeat view row. + if( $rvMedian ) + { echo ''; $rv_params = ParseCsiInfo($id, $testPath, $rvMedian, true, true); - echo ''; - } - else - { - echo ''; - } - } - } - echo ''; - ?> -
First View'; + echo ' (Run ' . $fvMedian . ')'; + foreach ( $test['testinfo']['extract_csi'] as $csi_param ) + { if( array_key_exists($csi_param, $fv_params) ) { - echo '' . $fv_params[$csi_param] . '' . $fv_params[$csi_param] . '
Repeat View'; - echo ' (Run ' . $rvMedian . ')'; - foreach ( $test['testinfo']['extract_csi'] as $csi_param ) - { - if( array_key_exists($csi_param, $rv_params) ) - { - echo '' . $rv_params[$csi_param] . '

- Repeat View'; + echo ' (Run ' . $rvMedian . ')'; + foreach ( $test['testinfo']['extract_csi'] as $csi_param ) + { + if( array_key_exists($csi_param, $rv_params) ) + { + echo '
' . $rv_params[$csi_param] . '
+

+ - - - -
- 1) - echo '

Test Results

'; + +
+ 1) + echo '

Test Results

'; - $runs = $test['test']['runs']; - $fvonly = 1; - if( isset($rv) ) - $fvonly = 0; - $first_displayed = false; - for( $run = 1; $run <= $runs; $run++) - { - $error_str = null; - if (array_key_exists('testinfo', $test) && - array_key_exists('errors', $test['testinfo']) && - array_key_exists($run, $test['testinfo']['errors']) && + $runs = $test['test']['runs']; + $fvonly = 1; + if( isset($rv) ) + $fvonly = 0; + $first_displayed = false; + for( $run = 1; $run <= $runs; $run++) + { + $error_str = null; + if (array_key_exists('testinfo', $test) && + array_key_exists('errors', $test['testinfo']) && + array_key_exists($run, $test['testinfo']['errors']) && strlen($test['testinfo']['errors'][$run])) { $error_str = 'Test Error: ' . $test['testinfo']['errors'][$run]; } elseif (!isset($pageData) || !is_array($pageData) || !array_key_exists($run, $pageData)) { if ($testComplete) - $error_str = 'Test Error: Data is missing.'; + $error_str = 'Test Error: Data is missing.'; else - $error_str = 'Waiting for test result...'; + $error_str = 'Waiting for test result...'; } if( $runs > 1 ) - echo '

Run ' . $run . ':

'; + echo '

Run ' . $run . ':

'; if (isset($error_str)) { echo '

' . htmlspecialchars($error_str) . '

'; } else { ?> - - - - - " class="pretty result" + align="center" border="1" cellpadding="20" cellspacing="0"> + + + + Screen Shot'; $table_columns++; } if($video) { - echo ''; - $table_columns++; - } - echo ''; - if (array_key_exists($run, $pageData) && array_key_exists(0, $pageData[$run]) && count($pageData[$run][0])) { - $onloadWaterfall = ''; - $onloadScreenShot = ''; - if (!$first_displayed) { + echo ''; + $table_columns++; + } + ?> + + + $pageData) + { + $onloadScreenShot = ''; + if (!$first_displayed) { $onloadWaterfall = " onload=\"markUserTime('aft.First Waterfall')\""; $onloadScreenShot = " onload=\"markUserTime('aft.First Screen Shot')\""; } $first_displayed = true; - echo ' + \n"; - if (!isset($test['testinfo']) || !$test['testinfo']['noimages']) { - if( FRIENDLY_URLS ) - echo ""; - else - echo ""; - } - if($video) { - echo '"; + else + echo "\n"; + if (!isset($test['testinfo']) || !$test['testinfo']['noimages']) { + if( FRIENDLY_URLS ) + echo ""; + else + echo ""; + } + if($video) { + echo ''; - } - } else { - echo ""; - } - echo ''; - if( isset($pageData[$run][1]) ) { - echo ''; - if (array_key_exists($run, $pageData) && array_key_exists(1, $pageData[$run]) && count($pageData[$run][1])) { - echo ''; + } + foreach($pageDataArray as $eventName => $pageData){ + if( isset($pageData[$run][1]) ) { ?> + + '; + echo ""; + echo ""; else - echo ""; + echo ""; if (!isset($test['testinfo']) || !$test['testinfo']['noimages']) { - if( FRIENDLY_URLS ) - echo ""; - else - echo ""; - } - if ($video) { - echo '"; + else + echo ""; + } + if ($video) { + echo ''; - } + } } else { - echo ""; + echo ""; } - echo ''; + echo ''; } - if( $testComplete && $run == $fvMedian ) { + } + if( $testComplete) { $b = getBreakdown($id, $testPath, $run, 0, $requests); if (is_array($b)) { $breakdown[] = array('run' => $run, 'data' => $b); } - ?> - - - "; - $extension = 'php'; - if( FRIENDLY_URLS ) - $extension = 'png'; - echo "
Waterfall
WaterfallVideo
Video
First View'; - if( isset($pageData[$run][0]['result']) && $pageData[$run][0]['result'] !== 0 && $pageData[$run][0]['result'] !== 99999 ) - echo '
(Error: ' . LookupError($pageData[$run][0]['result']) . ')'; - else if( isset($pageData[$run][0]['loadTime']) ) - echo '
(' . number_format($pageData[$run][0]['loadTime'] / 1000.0, 3) . 's)'; - if( is_file("$testPath/{$run}_dynaTrace.dtas") ) - { - echo "

\"Download

"; - echo "\"Get"; - } - if( gz_is_file("$testPath/{$run}.cap") ) - { - $tcpdump_url = "/getgzip.php?test=$id&file=$run.cap"; - if( FRIENDLY_URLS ) - $tcpdump_url = "/result/$id/{$run}.cap"; - echo "

tcpdump"; - if (array_key_exists('tcpdump_view', $settings) && strlen($settings['tcpdump_view'])) { + ?> +
First View
+ (Error: ' . LookupError($pageData[$run][0]['result']) . ')'; + else if( isset($pageData[$run][0]['loadTime']) ) + echo '
(' . number_format($pageData[$run][0]['loadTime'] / 1000.0, 3) . 's)'; + if( is_file("$testPath/{$run}_dynaTrace.dtas") ) + { + echo "

\"Download

"; + echo "\"Get"; + } + if( gz_is_file("$testPath/{$run}.cap") ) + { + $tcpdump_url = "/getgzip.php?test=$id&file=$run.cap"; + if( FRIENDLY_URLS ) + $tcpdump_url = "/result/$id/{$run}.cap"; + echo "

tcpdump"; + if (array_key_exists('tcpdump_view', $settings) && strlen($settings['tcpdump_view'])) { $view_url = $settings['tcpdump_view'] . urlencode("http://$wpt_host$tcpdump_url"); echo " - (view)"; - } - } - if( gz_is_file("$testPath/{$run}_timeline.json") || gz_is_file("$testPath/{$run}_devtools.json") ) { + } + } + if( gz_is_file("$testPath/{$run}_timeline.json") || gz_is_file("$testPath/{$run}_devtools.json") ) { echo "

Timeline"; echo " (view)"; if (array_key_exists('testinfo', $test) && array_key_exists('timeline', $test['testinfo']) && $test['testinfo']['timeline']) - echo "
Processing Breakdown"; + echo "
Processing Breakdown"; } if( gz_is_file("$testPath/{$run}_netlog.txt") ) { echo "

Net Log"; @@ -452,66 +516,68 @@ $page_description = "Website performance test result$testLabel."; echo '
'; $testUrl = "/details.php?test=$id&run=$run"; if ($run == $fvMedian && array_key_exists('end', $_REQUEST)) - $testUrl .= "&end={$_REQUEST['end']}"; + $testUrl .= "&end={$_REQUEST['end']}"; elseif (FRIENDLY_URLS) - $testUrl = "/result/$id/$run/details/"; - echo ""; - echo "'; - if (is_dir("$testPath/video_$run")) { + $testUrl = "/result/$id/$run/details/"; + echo ""; + if( FRIENDLY_URLS ) + echo "'; + if (is_dir("$testPath/video_$run")) { $end = ''; $endId = ''; if ($run == $fvMedian && array_key_exists('end', $_REQUEST)) { $end = "-e:{$_REQUEST['end']}"; $endId = "-e{$_REQUEST['end']}"; - } - echo "Filmstrip View
-
"; - echo "Watch Video"; - //echo "
-
Compare to"; + } + echo "Filmstrip View
-
"; + echo "Watch Video"; + //echo "
-
Compare to"; } else - echo "not available"; + echo "not available"; echo '
First View: Test Data Missing
Repeat View'; - if( isset($pageData[$run][1]['result']) && $pageData[$run][1]['result'] !== 0 && $pageData[$run][1]['result'] !== 99999 ) - echo '
(Error: ' . LookupError($pageData[$run][1]['result']) . ')'; - else if( isset($pageData[$run][1]['loadTime']) ) - echo '
(' . number_format($pageData[$run][1]['loadTime'] / 1000.0, 3) . 's)'; - if( is_file("$testPath/{$run}_Cached_dynaTrace.dtas") ) - { - echo "

\"Download

"; - echo "\"Get"; - } - if( gz_is_file("$testPath/{$run}_Cached.cap") ) - { - $tcpdump_url = "/getgzip.php?test=$id&file={$run}_Cached.cap"; - if( FRIENDLY_URLS ) - $tcpdump_url = "/result/$id/{$run}_Cached.cap"; - echo "

tcpdump"; - if (array_key_exists('tcpdump_view', $settings) && strlen($settings['tcpdump_view'])) { + } + echo '
Repeat View
+ (Error: ' . LookupError($pageData[$run][1]['result']) . ')'; + else if( isset($pageData[$run][1]['loadTime']) ) + echo '
(' . number_format($pageData[$run][1]['loadTime'] / 1000.0, 3) . 's)'; + if( is_file("$testPath/{$run}_Cached_dynaTrace.dtas") ) + { + echo "

\"Download

"; + echo "\"Get"; + } + if( gz_is_file("$testPath/{$run}_Cached.cap") ) + { + $tcpdump_url = "/getgzip.php?test=$id&file={$run}_Cached.cap"; + if( FRIENDLY_URLS ) + $tcpdump_url = "/result/$id/{$run}_Cached.cap"; + echo "

tcpdump"; + if (array_key_exists('tcpdump_view', $settings) && strlen($settings['tcpdump_view'])) { $view_url = $settings['tcpdump_view'] . urlencode("http://$wpt_host$tcpdump_url"); echo " - (view)"; - } - } - if( gz_is_file("$testPath/{$run}_Cached_timeline.json") || gz_is_file("$testPath/{$run}_Cached_devtools.json") ) { + } + } + if( gz_is_file("$testPath/{$run}_Cached_timeline.json") || gz_is_file("$testPath/{$run}_Cached_devtools.json") ) { echo "

Timeline"; echo " (view)"; if (array_key_exists('testinfo', $test) && array_key_exists('timeline', $test['testinfo']) && $test['testinfo']['timeline']) - echo "
Processing Breakdown"; + echo "
Processing Breakdown"; } if( gz_is_file("$testPath/{$run}_Cached_netlog.txt") ) { echo "

Net Log"; @@ -520,74 +586,80 @@ $page_description = "Website performance test result$testLabel."; echo "

Trace"; } echo '
"; if( FRIENDLY_URLS ) - echo "'; - if (is_dir("$testPath/video_{$run}_cached")) { - echo "Filmstrip View
-
"; - echo "Watch Video"; + if( FRIENDLY_URLS ) + echo "
'; + if (is_dir("$testPath/video_{$run}_cached")) { + echo "Filmstrip View
-
"; + echo "Watch Video"; } else - echo "not available"; + echo "not available"; echo '
Repeat View: Test Data MissingRepeat View: Test Data for Event Name \"".$eventName."\" missing
">Content Breakdown
"; - echo "
"; - ?> - - - - -
- + + + ">Content + Breakdown
(Preview for all Events) + "; + $extension = 'php'; + if( FRIENDLY_URLS ) + $extension = 'png'; + echo ""; + echo "
"; + ?> + + + + + + +
+ -
-
+ ?> + + + +
+ +
-
- -
- - - - - + - + diff --git a/www/results.php b/www/results.php index 71a1e0b307..adda431a17 100644 --- a/www/results.php +++ b/www/results.php @@ -27,11 +27,12 @@ include 'testcancelled.inc'; elseif( (isset($test['test']) && isset($test['test']['completeTime'])) || count($pageData) > 0 ) { - if( @$test['test']['type'] == 'traceroute' ) + if( @$test['test']['type'] == 'traceroute' ){ include 'resultTraceroute.inc'; - else + } else { include 'result.inc'; } + } else include 'running.inc'; } diff --git a/www/screen_shot.php b/www/screen_shot.php index 397f44fac8..1907f36194 100644 --- a/www/screen_shot.php +++ b/www/screen_shot.php @@ -1,9 +1,11 @@ +
+

+ +

+
+
+

Quicklinks

Back to page top +
+ + + + + + + + + + + + + +
Event NameScreenshots
ScSh #
+
+


"; + foreach($pageRunDataArray as $eventName => $pageRunData){ + echo "

".$eventName."

"; + echo "Back to Quicklinks"; + $pageString = "_" . $pageRunData['pageNumber']; + echo "


"; + if( is_dir("./$videoPath") ) { $createPath = "/video/create.php?tests=$id-r:$run-c:$cached&id={$id}.{$run}.{$cached}"; @@ -101,18 +143,18 @@ if($cached == 1) $cachedText='_Cached'; - if( is_file($testPath . '/' . $run . $cachedText . '_screen.png') ) + if( is_file($testPath . '/' . $run . $cachedText . $pageString . '_screen.png') ) { echo '

Fully Loaded

'; - echo ''; - echo 'Screen Shot'; + echo ''; + echo 'Screen Shot'; echo ''; } - elseif( is_file($testPath . '/' . $run . $cachedText . '_screen.jpg') ) + elseif( is_file($testPath . '/' . $run . $cachedText . $pageString . '_screen.jpg') ) { echo '

Fully Loaded

'; - echo ''; - echo 'Screen Shot'; + echo ''; + echo 'Screen Shot'; echo ''; } // display the last status message if we have one @@ -123,38 +165,38 @@ echo "\n
Last Status Message: \"{$lastMessage['message']}\"\n"; } - if( is_file($testPath . '/' . $run . $cachedText . '_screen_render.jpg') ) + if( is_file($testPath . '/' . $run . $cachedText . $pageString . '_screen_render.jpg') ) { echo '

Start Render'; if( isset($pageRunData) && isset($pageRunData['render']) ) echo ' (' . number_format($pageRunData['render'] / 1000.0, 3) . ' sec)'; echo '

'; - echo 'Start Render Screen Shot'; + echo 'Start Render Screen Shot'; } - if( is_file($testPath . '/' . $run . $cachedText . '_screen_dom.jpg') ) + if( is_file($testPath . '/' . $run . $cachedText . $pageString . '_screen_dom.jpg') ) { echo '

DOM Element'; if( isset($pageRunData) && isset($pageRunData['domTime']) ) echo ' (' . number_format($pageRunData['domTime'] / 1000.0, 3) . ' sec)'; echo '

'; - echo 'DOM Element Screen Shot'; + echo 'DOM Element Screen Shot'; } - if( is_file($testPath . '/' . $run . $cachedText . '_screen_doc.jpg') ) + if( is_file($testPath . '/' . $run . $cachedText . $pageString . '_screen_doc.jpg') ) { echo '

Document Complete'; if( isset($pageRunData) && isset($pageRunData['docTime']) ) echo ' (' . number_format($pageRunData['docTime'] / 1000.0, 3) . ' sec)'; echo '

'; - echo 'Document Complete Screen Shot'; + echo 'Document Complete Screen Shot'; } - if( is_file($testPath . '/' . $run . $cachedText . '_aft.png') ) + if( is_file($testPath . '/' . $run . $cachedText . $pageString . '_aft.png') ) { echo '

AFT Details'; if( isset($pageRunData) && isset($pageRunData['aft']) ) echo ' (' . number_format($pageRunData['aft'] / 1000.0, 3) . ' sec)'; echo '

'; echo 'White = Stabilized Early, Blue = Dynamic, Red = Late Static (failed AFT), Green = AFT
'; - echo 'AFT Diagnostic image'; + echo 'AFT Diagnostic image'; } // display all of the status messages @@ -185,6 +227,9 @@ } echo "\n"; } + echo "

"; + echo "

"; + } ?> diff --git a/www/thumbnail.php b/www/thumbnail.php index e2e89b0d2a..786b118cf1 100644 --- a/www/thumbnail.php +++ b/www/thumbnail.php @@ -17,7 +17,12 @@ include 'common.inc'; include 'object_detail.inc'; require_once('page_data.inc'); - $file = $_GET['file']; + $file = $_REQUEST['file']; + if(isset($_REQUEST['eventName'])){ + $eventName = urldecode($_REQUEST['eventName']); + } else { + $eventName = null; + } // make sure nobody is trying to use us to pull down external images from somewhere else if( strpos($file, ':') === FALSE && @@ -38,11 +43,11 @@ // see if it is a waterfall image if( strstr($parts['basename'], 'waterfall') !== false ) { - tbnDrawWaterfall($img); + tbnDrawWaterfall($img, $eventName); } elseif( strstr($parts['basename'], 'optimization') !== false ) { - tbnDrawChecklist($img); + tbnDrawChecklist($img, $eventName); } else { if( !is_file("$testPath/$file") ) { @@ -62,10 +67,11 @@ if( $img ) { + $path = $testPath . "/" . urlencode($file); header('Last-Modified: ' . gmdate('r')); header('Expires: '.gmdate('r', time() + 31536000)); GenerateThumbnail($img, $type); - SendImage($img, $type); + SendImage($img, $type, $path); } else { @@ -79,7 +85,7 @@ * * @param resource $img */ -function tbnDrawWaterfall(&$img) +function tbnDrawWaterfall(&$img, $eventName = null) { global $id; global $testPath; @@ -92,8 +98,14 @@ function tbnDrawWaterfall(&$img) include('waterfall.inc'); $is_secure = false; $has_locations = false; - $requests = getRequests($id, $testPath, $run, $cached, $is_secure, - $has_locations, false); + if($eventName != null){ + $requestsArray = getRequests($id, $testPath, $run, $cached, $is_secure, + $has_locations, false, false, true); + $requests = $requestsArray[$eventName]; + } else { + $requests = getRequests($id, $testPath, $run, $cached, $is_secure, + $has_locations, false, false); + } $use_dots = (!isset($_REQUEST['dots']) || $_REQUEST['dots'] != 0); $rows = GetRequestRows($requests, $use_dots); $page_data = loadPageRunData($testPath, $run, $cached); @@ -126,7 +138,7 @@ function tbnDrawWaterfall(&$img) * * @param resource $img */ -function tbnDrawChecklist(&$img) +function tbnDrawChecklist(&$img, $eventName = null) { global $id; global $testPath; @@ -137,7 +149,12 @@ function tbnDrawChecklist(&$img) include('optimizationChecklist.inc'); $is_secure = false; $has_locations = false; + if($eventName != null){ + $requestsArray = getRequests($id, $testPath, $run, $cached, $is_secure, $has_locations, false, false, true); + $requests = $requestsArray[$eventName]; + } else { $requests = getRequests($id, $testPath, $run, $cached, $is_secure, $has_locations, false); + } $page_data = loadPageRunData($testPath, $run, $cached); $img = drawChecklist($url, $requests, $page_data); if (!$requests || !$page_data) { @@ -193,8 +210,10 @@ function GenerateThumbnail(&$img, $type) * * @param mixed $img * @param mixed $type +* @param mixed $path +* path to save image to */ -function SendImage(&$img, $type) +function SendImage(&$img, $type, $path = null) { // output the image if( !strcasecmp( $type, 'jpg') ) @@ -206,6 +225,9 @@ function SendImage(&$img, $type) else { header ("Content-type: image/png"); + if($path != null){ + imagepng($img, $path); + } imagepng($img); } } diff --git a/www/utils.inc b/www/utils.inc new file mode 100644 index 0000000000..73c93000ff --- /dev/null +++ b/www/utils.inc @@ -0,0 +1,176 @@ +] + * [$subEventArray][] (optional) + * [$subArray1] (optional) + * [$subArray2] (optional) + * [$key] + * + * Checks for each event element in $array: + * + * (array_key_exists( $key, + * $array[$eventName] + * [$subEventArray][] + * [$subArray1] + * [$subArray2] + * [$key]) && + * ($cast) (optional) + * ($array[$eventName] + * [$subEventArray][] + * [$subArray1] + * [$subArray2] + * [$key]) $operator $compare + * + * e.g.: checkForAllEventNames($pageDataArray, 'domTime', '>', 0.0, "float", -1, $fvMedian, 0): + * + * $result = true; + * For all events as $eventName + * $result |= (array_key_exists('domTime', $pageDataArray[][$fvMedian][0]) && + * (float)$pageDataArray[$eventName][$fvMedian][0] > 0.0) + * + * + * @param array $array + * array containing all event data + * @param string $key + * key that should be compared for each event + * @param string $operator + * operator to compare as string + * @param mixed $compare + * value to compare with + * @param string $cast + * casts the array value to a specific type if defined (optional, as string) + * @param string $subEventArray + * array key to reach access subArray which also contains event names keys (optional) + * @param string $subArray1 + * array key to reach access to subArray (optional) + * @return boolean + * returns if in one event the condition is fulfilled + */ + function checkForAllEventNames($array, $key, $operator, $compare, $cast=null, $subEventArray=-1, $subArray1=-1, $subArray2=-1){ + $result = false; + $code = '$result |= (array_key_exists($key, $array[$eventName]'; + if($subEventArray != -1){ + $code .= '[$subEventArray][$eventName]'; + } + if($subArray1 != -1){ + $code .= '[$subArray1]'; + } + if($subArray2 != -1){ + $code .= '[$subArray2]'; + } + $code .= ') && ('; + if($cast != null){ + $code .= '('.$cast.')'; + } + $code .= '$array[$eventName]'; + if($subEventArray != -1){ + $code .= '[$subEventArray][$eventName]'; + } + if($subArray1 != -1){ + $code .= '[$subArray1]'; + } + if($subArray2 != -1){ + $code .= '[$subArray2]'; + } + $code .= '[$key]'; + $code .=') '.$operator.' $compare);'; + foreach(array_keys($array) as $eventName){ + eval($code); + } + return $result; + } +?> \ No newline at end of file diff --git a/www/video/compare.php b/www/video/compare.php index 4329c35f6d..4b082cbc21 100644 --- a/www/video/compare.php +++ b/www/video/compare.php @@ -308,12 +308,12 @@ function UpdateScrollPosition() { var marker = parseInt(padLeft + ((position / width) * (930 - padLeft))); $('#marker').css('left', marker + 'px'); } - UpdateScrollPosition(); - + UpdateScrollPosition(); + diff --git a/www/waterfall.css b/www/waterfall.css index b4248742ce..ef9a100c78 100644 --- a/www/waterfall.css +++ b/www/waterfall.css @@ -4,10 +4,10 @@ img.waterfall-image {position: relative; left: 0; top: 0;} div.request-overlay {cursor:pointer; padding: 0; margin: 0; width: 928px; left: 1px; background-color: #FFF; overflow: hidden; opacity:0.9; filter:alpha(opacity=90);} div.request-overlay.selected {opacity:0.4; background-color: #129828;} div.transparent {opacity:0.0; filter:alpha(opacity=0);} -#dialog-title {display: inline;} -#dialog-title a {color: #fff;} -#request-dialog-radio {display:inline; padding-left: 20px; font-weight: normal; } -#request-headers, #response-headers, #response-body {display:none;} +.dialog-title {display: inline;} +.dialog-title a {color: #fff;} +.request-dialog-radio {display:inline; padding-left: 20px; font-weight: normal; } +.request-headers, .response-headers, .response-body {display:none;} .jqmWindow {display: none; position: fixed; top: 17%; left: 50%; margin-left: -300px; width: 600px; background-color: #dfdfdf; color: #333; border: 1px solid black; padding: 12px; } .jqmOverlay { background-color: #000; } diff --git a/www/waterfall.inc b/www/waterfall.inc index 7d617e0104..0252be7a42 100644 --- a/www/waterfall.inc +++ b/www/waterfall.inc @@ -1,11 +1,12 @@ false, @@ -59,8 +60,8 @@ function _GetDotsRow() { } /** -* Return an array of rows to use in waterfall view. -*/ + * Return an array of rows to use in waterfall view. + */ function GetRequestRows($requests, $use_dots, $show_labels = true) { $rows = array(); $filtered_requests = FilterRequests($requests); @@ -86,8 +87,8 @@ function GetRequestRows($requests, $use_dots, $show_labels = true) { } /** -* Return an array of page events selected from the page data. -*/ + * Return an array of page events selected from the page data. + */ function GetPageEvents($page_data) { return array( 'render' => $page_data['render'], @@ -103,8 +104,8 @@ function GetPageEvents($page_data) { } /** -* Return data for an image map of the given rows. -*/ + * Return data for an image map of the given rows. + */ function GetWaterfallMap($rows, $url, $options, &$page_data) { $page_events = array(); $is_image_map = true; @@ -112,20 +113,20 @@ function GetWaterfallMap($rows, $url, $options, &$page_data) { } /** -* Return an image identifier (from imagecreate) for a waterfall chart. -* -* @return resource -*/ + * Return an image identifier (from imagecreate) for a waterfall chart. + * + * @return resource + */ function GetWaterfallImage($rows, $url, $page_events, $options, &$page_data) { $is_image_map = false; return _GetMapOrImage($rows, $url, $page_events, $options, $is_image_map, $page_data); } /** -* Draw the waterfall view image. -* -* @return resource -*/ + * Draw the waterfall view image. + * + * @return resource + */ function _GetMapOrImage($rows, $url, $page_events, $options, $is_image_map, &$page_data) { global $settings; $is_mime = (bool)@$options['is_mime']; @@ -589,19 +590,38 @@ function _GetMapOrImage($rows, $url, $page_events, $options, $is_image_map, &$pa } } - if ($is_image_map) - return $map; - else - return $im; + if ($is_image_map) { + return $map; + } else { + return $im; + } } /** -* Filter the requests we choose to display -* -* @param mixed $requests -*/ + * Checks if a request hostname contains string of requested hosts + * @param array $requestHost + * request hostname + * @param string $hosts + * array that contains requested hosts substrings + * @return boolean + * Does the request hostname belong to the requested hostnames? + */ +function checksRequestHost($requestHost, $hosts){ + $result = false; + foreach($hosts as $host){ + $host = trim($host); + $result |= (strlen(stristr($requestHost, $host)) > 0); + } + return $result; +} + +/** + * Filter the requests we choose to display + * + * @param mixed $requests + */ function FilterRequests($requests) { - $filtered_requests = array(); + $filtered_requests_number = array(); if (array_key_exists('requests', $_REQUEST) && strlen(trim($_REQUEST['requests']))) { $rlist = explode(',', urldecode($_REQUEST['requests'])); foreach ($rlist as $r) { @@ -614,20 +634,33 @@ function FilterRequests($requests) { $end = min(count($requests) - 1, $range[1] - 1); if ($end > $start) { for ($i = $start; $i <= $end; $i++) { - $filtered_requests[$i] = &$requests[$i]; + $filtered_requests_number[$i] = &$requests[$i]; } } } elseif ($r > 0 && $r <= count($requests)) { - $filtered_requests[$r - 1] = &$requests[$r - 1]; + $filtered_requests_number[$r - 1] = &$requests[$r - 1]; } } } } - - if (!count($filtered_requests)) - $filtered_requests = $requests; - - return $filtered_requests; + + if (!count($filtered_requests_number)) + $filtered_requests_number = $requests; + + $filtered_requests_hosts = array(); + if (array_key_exists('hosts', $_REQUEST) && strlen(trim($_REQUEST['hosts']))) { + $hostList = explode(',', urldecode($_REQUEST['hosts'])); + foreach($filtered_requests_number as $index => $request){ + if(array_key_exists('host', $request) && checksRequestHost($request['host'], $hostList)){ + $filtered_requests_hosts[$index] = $request; + } + } + } + + if (!count($filtered_requests_hosts)) + $filtered_requests_hosts = $filtered_requests_number; + + return $filtered_requests_hosts; } class ColorAlternator @@ -667,8 +700,8 @@ class XScaler } /** -* -*/ + * + */ function AddRowCoordinates(&$rows, $y1, $row_height) { foreach ($rows as &$r) { $r['y1'] = $y1; @@ -678,7 +711,7 @@ function AddRowCoordinates(&$rows, $y1, $row_height) { } /* Add 'bg_color' to each row. -*/ + */ function SetRowColors(&$rows, $is_page_loaded, $bg_colors) { $row_color_alternator = new ColorAlternator($bg_colors['alt'], $bg_colors['default']); @@ -698,14 +731,14 @@ function SetRowColors(&$rows, $is_page_loaded, $bg_colors) { } /** -* Draw performance chart label. -* -* @param resource $im is an image resource. -* @param string $key is which performance chart (e.g. 'cpu' or 'bw'). -* @param mixed $perf is an array of performance parameters. -* @param int $font is the label's font indentifier. -* @param int $label_color color identifier -*/ + * Draw performance chart label. + * + * @param resource $im is an image resource. + * @param string $key is which performance chart (e.g. 'cpu' or 'bw'). + * @param mixed $perf is an array of performance parameters. + * @param int $font is the label's font indentifier. + * @param int $label_color color identifier + */ function DrawPerfLabel($im, $key, $perf, $font, $label_color) { $x = $perf['x1']; $height = $perf['height']; @@ -725,14 +758,14 @@ function DrawPerfLabel($im, $key, $perf, $font, $label_color) { } /** -* Draw performance chart background. -* -* @param resource $im is an image resource. -* @param mixed $perf is an array of performance parameters. -* @param int $data_x is where the data area of the chart begins. -* @param int $border_color color identifier -* @param int $bg_color color identifier -*/ + * Draw performance chart background. + * + * @param resource $im is an image resource. + * @param mixed $perf is an array of performance parameters. + * @param int $data_x is where the data area of the chart begins. + * @param int $border_color color identifier + * @param int $bg_color color identifier + */ function DrawPerfBackground($im, $perf, $data_x, $border_color, $bg_color) { $x1 = $perf['x1']; $x2 = $perf['x2']; @@ -752,8 +785,8 @@ function DrawPerfBackground($im, $perf, $data_x, $border_color, $bg_color) { } /** -* Return marker interval best fit. -*/ + * Return marker interval best fit. + */ function TimeScaleInterval($max_ms, $target_count) { $target_interval = (float)$max_ms / (float)$target_count; $interval = $target_interval; @@ -771,9 +804,9 @@ function TimeScaleInterval($max_ms, $target_count) { } /** -* Format the label for the time scale. -* @return string -*/ + * Format the label for the time scale. + * @return string + */ function TimeScaleLabel($ms, $interval) { $places = 2; if ($interval >= 1000) { @@ -785,17 +818,17 @@ function TimeScaleLabel($ms, $interval) { } /** -* Draw $label centered at $x. -*/ + * Draw $label centered at $x. + */ function DrawCenteredText($im, $x, $y, $label, $font, $font_width, $color) { $x -= (int)((double)$font_width * (double)strlen($label) / 2.0); imagestring($im, $font, $x, $y, $label, $color); } /** -* Format the label for a request. -* @return string -*/ + * Format the label for a request. + * @return string + */ function GetRequestLabel($request, $show_labels = true) { $path = parse_url('http://' . $request['host'] . $request['url'], PHP_URL_PATH); @@ -813,8 +846,8 @@ function GetRequestLabel($request, $show_labels = true) { } /** -* Append imagemap data for the main document url. -*/ + * Append imagemap data for the main document url. + */ function AddMapUrl(&$map, $x1, $y1, $x2, $y2, $url) { $map[] = array( 'url' => $url, @@ -825,8 +858,8 @@ function AddMapUrl(&$map, $x1, $y1, $x2, $y2, $url) { } /** -* Append imagemap data for a single request. -*/ + * Append imagemap data for a single request. + */ function AddMapRequest(&$map, $x1, $y1, $x2, $y2, $request) { $scheme = $request['is_secure'] ? 'https://' : 'http://'; $map[] = array( @@ -852,9 +885,9 @@ function AddMapUserTime(&$map, $x1, $y1, $x2, $y2, $label) { /** -* Return an array of 'bars' which define the coordinates and colors -* for the parts of a request. -*/ + * Return an array of 'bars' which define the coordinates and colors + * for the parts of a request. + */ function GetBars($request, $x_scaler, $y1, $y2, $is_thumbnail, $is_mime, $is_state) { $bars = array(); @@ -879,8 +912,8 @@ function GetBars($request, $x_scaler, $y1, $y2, } /** -* Append a bar for a request part if it exists and is valid. -*/ + * Append a bar for a request part if it exists and is valid. + */ function AddBarIfValid(&$bars, $key, $request, $x_scaler, $y1, $y2) { $start_key = $key . '_start'; $end_key = $key . '_end'; @@ -900,12 +933,12 @@ function AddBarIfValid(&$bars, $key, $request, $x_scaler, $y1, $y2) { } /** -* Insert an interactive waterfall into the current page -* -*/ -function InsertWaterfall($url, &$requests, $id, $run, $cached, &$page_data, $waterfall_options = '') { - global $settings; - + * Insert an interactive waterfall into the current page + * + */ +function InsertWaterfall($url, &$requests, $id, $run, $cached, $waterfall_options = '', $eventName = null) { + global $settings; + // create the image map (this is for fallback when Javascript isn't enabled // but also gives us the position for each request) echo ''; @@ -918,8 +951,12 @@ function InsertWaterfall($url, &$requests, $id, $run, $cached, &$page_data, $wat 'show_labels' => true, 'width' => 930 ); + if($eventName != null){ + $rows = GetRequestRows($requests[$eventName], false); + } else { $rows = GetRequestRows($requests, false); - $map = GetWaterfallMap($rows, $url, $options, $page_data); + } + $map = GetWaterfallMap($rows, $url, $options); foreach($map as $entry) { if (array_key_exists('request', $entry)) { $index = $entry['request'] + 1; @@ -932,10 +969,10 @@ function InsertWaterfall($url, &$requests, $id, $run, $cached, &$page_data, $wat } } echo ''; - + // main container for the waterfall echo '
'; - echo "\"\""; + echo "\"\""; // draw div's over each of the waterfall elements (use the image map as a reference) foreach($map as $entry) { @@ -950,39 +987,63 @@ function InsertWaterfall($url, &$requests, $id, $run, $cached, &$page_data, $wat $tooltip = substr($tooltip, 0, $split) . '...'; $tooltip = FitText($tooltip, 100); } - echo "
\n"; + echo "
\n"; } - } - + } ?> -
-
-
-
- - - - +
+
+
+
+ +
-
-
-
-
-
+
+
+
+
+
-
-
- +
+'; // container - - // script support +echo '
'; // container + +// script support + if($eventName != null){ + $eventCount = array(); + foreach(array_keys($requests) as $page){ + $eventCount[$page] = count($requests[$eventName]); + } + } else { + $eventCount = count($requests); + } echo ""; diff --git a/www/waterfall.js b/www/waterfall.js index 3707e6a7bf..2b7d8851d4 100644 --- a/www/waterfall.js +++ b/www/waterfall.js @@ -1,30 +1,51 @@ -var CloseRequestDialog = function(hash) { +var wptBodyRequest; + +function initDialog(eventName) { + var eventNameID = eventName.replace(/ /g, "_"); + var CloseRequestDialog = function(hash) { hash.w.hide(); - for (i=1;i<=wptRequestCount;i++) { - $("#request-overlay-" + i).removeClass("selected"); - $("#request-overlay-" + i).addClass("transparent"); + if (eventName != -1) { + var requestCount = wptRequestCount[eventName]; + } else { + var requestCount = wptRequestCount; } - $('#radio1').attr('checked', 'checked'); - $("#request-dialog-radio").buttonset('refresh'); -} + for (i = 1; i <= requestCount; i++) { + $("#request-overlay-" + eventNameID + "-" + i).removeClass( + "selected"); + $("#request-overlay-" + eventNameID + "-" + i).addClass( + "transparent"); + } + $('#radio' + eventNameID + '1').attr('checked', 'checked'); + $("#request-dialog-radio" + eventNameID).buttonset('refresh'); + } -// initialize the pop-up dialog -$('#request-dialog').jqm({overlay: 0, onHide: CloseRequestDialog}) - .jqDrag('.jqDrag'); -$('input.jqmdX') - .hover( function(){ $(this).addClass('jqmdXFocus'); }, - function(){ $(this).removeClass('jqmdXFocus'); }) - .focus( function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); }) - .blur( function(){ $(this).removeClass('jqmdXFocus'); }); - -$("#request-dialog-radio").buttonset(); -$("#request-dialog-radio").change(function() { - var panel=$('#request-dialog-radio input[type=radio]:checked').val(); - $("#dialog-contents div.dialog-tab-content").hide(); - $("#" + panel).show(); -}); + // initialize the pop-up dialog + $('#request-dialog' + eventNameID).jqm({ + overlay : 0, + onHide : CloseRequestDialog + }).jqDrag('.jqDrag'); + $('input.jqmdX').hover(function() { + $(this).addClass('jqmdXFocus'); + }, function() { + $(this).removeClass('jqmdXFocus'); + }).focus(function() { + this.hideFocus = true; + $(this).addClass('jqmdXFocus'); + }).blur(function() { + $(this).removeClass('jqmdXFocus'); + }); -var wptBodyRequest; + $("#request-dialog-radio" + eventNameID).buttonset(); + $("#request-dialog-radio" + eventNameID).change( + function() { + var panel = $( + '#request-dialog-radio' + eventNameID + + ' input[type=radio]:checked').val(); + $("#dialog-contents" + eventNameID + " div.dialog-tab-content") + .hide(); + $("#" + panel).show(); + }); +} // Test that a value is a valid duration. // Invalid durations include undefined and -1. @@ -54,28 +75,71 @@ function NumBytesAsDisplayString(numBytes) { return numBytes + ' B'; } -function SelectRequest(request) { - $('#request-dialog').css('top', $("#request-overlay-" + request).position().top + 20); - $("#dialog-title").html('Request #' + request + ''); - var details=''; - var requestHeaders=''; - var responseHeaders=''; - $("#response-body").html(''); - $('#response-body-button').hide(); - $("#response-image").html(''); - $('#response-image-button').hide(); - try { - if (wptBodyRequest !== undefined) - wptBodyRequest.abort(); - } catch (err) { +/** + * Changes the header format (adding bold tags to row types) + * + * @param header + * header to reformat + * @returns {String} reformatted header + */ +function reformatHeaders(header) { + var rows = header.split("
"); + var result = ""; + for ( var i in rows) { + var entries = rows[i].split(":"); + if (entries.length > 1) { + result = result + "" + entries[0] + ":" + entries[1]; + if(entries.length > 2){ + for(var j = 2; j < entries.length; j++){ + result = result + ":" + entries[j]; } - if (wptRequestData[request - 1] !== undefined) { - var r = wptRequestData[request - 1]; + } + } else { + result = result += rows[i]; + } + result += "
"; + } + return result; +} + +/** + * Result type for the request details result + */ +var eResultType = { + DETAILS : 0, + REQUEST_HEADERS : 1, + RESPONSE_HEADERS : 2 +} + +/** + * Returns the request details according to given result type + * + * @param eventName + * eventName of the request + * @param request + * number of the request + * @param resultType + * value of eResultType enum + * @returns request details belonging to the result type + */ +function getRequestDetails(eventName, request, resultType) { + var wptRequests; + if (eventName != -1) { + wptRequests = wptRequestData[eventName]; + } else { + wptRequests = wptRequestData; + } + if (wptRequests !== undefined && wptRequests[request - 1] !== undefined) { + var r = wptRequests[request - 1]; + if (resultType == eResultType.DETAILS) { + var details = ''; if (r['full_url'] !== undefined) { if (wptNoLinks) { details += 'URL: ' + r['full_url'] + '
'; } else { - details += 'URL: ' + r['full_url'] + '
'; + details += "URL: " + r['full_url'] + + "
"; } } if (r['initiator'] !== undefined && r['initiator'].length > 0) { @@ -91,96 +155,173 @@ function SelectRequest(request) { if (r['location'] !== undefined && r['location'].length) details += 'Location: ' + r['location'] + '
'; if (r['responseCode'] !== undefined) - details += 'Error/Status Code: ' + r['responseCode'] + '
'; + details += 'Error/Status Code: ' + r['responseCode'] + + '
'; if (r['client_port'] !== undefined && r['client_port']) details += 'Client Port: ' + r['client_port'] + '
'; if (r['load_start'] !== undefined) - details += 'Start Offset: ' + (r['load_start'] / 1000.0).toFixed(3) + ' s
'; + details += 'Start Offset: ' + + (r['load_start'] / 1000.0).toFixed(3) + ' s
'; if (IsValidDuration(r['dns_ms'])) { details += 'DNS Lookup: ' + r['dns_ms'] + ' ms
'; - } else if( r['dns_end'] !== undefined && r['dns_start'] !== undefined && r['dns_end'] > 0 ) { + } else if (r['dns_end'] !== undefined + && r['dns_start'] !== undefined && r['dns_end'] > 0) { var dnsTime = r['dns_end'] - r['dns_start']; details += 'DNS Lookup: ' + dnsTime + ' ms
'; } if (IsValidDuration(r['connect_ms'])) { - details += 'Initial Connection: ' + r['connect_ms'] + ' ms
'; - if (r['is_secure'] !== undefined && r['is_secure'] && IsValidDuration(r['ssl_ms'])) { - details += 'SSL Negotiation: ' + r['ssl_ms'] + ' ms
'; + details += 'Initial Connection: ' + r['connect_ms'] + + ' ms
'; + if (r['is_secure'] !== undefined && r['is_secure'] + && IsValidDuration(r['ssl_ms'])) { + details += 'SSL Negotiation: ' + r['ssl_ms'] + + ' ms
'; } - } else if( r['connect_end'] !== undefined && r['connect_start'] !== undefined && r['connect_end'] > 0 ) { + } else if (r['connect_end'] !== undefined + && r['connect_start'] !== undefined && r['connect_end'] > 0) { var connectTime = r['connect_end'] - r['connect_start']; - details += 'Initial Connection: ' + connectTime + ' ms
'; - if( r['ssl_end'] !== undefined && r['ssl_start'] !== undefined && r['ssl_end'] > 0 ) { + details += 'Initial Connection: ' + connectTime + + ' ms
'; + if (r['ssl_end'] !== undefined && r['ssl_start'] !== undefined + && r['ssl_end'] > 0) { var sslTime = r['ssl_end'] - r['ssl_start']; details += 'SSL Negotiation: ' + sslTime + ' ms
'; } } if (IsValidDuration(r['ttfb_ms'])) { - details += 'Time to First Byte: ' + r['ttfb_ms'] + ' ms
'; + details += 'Time to First Byte: ' + r['ttfb_ms'] + + ' ms
'; } if (IsValidDuration(r['download_ms'])) - details += 'Content Download: ' + r['download_ms'] + ' ms
'; + details += 'Content Download: ' + r['download_ms'] + + ' ms
'; if (r['bytesIn'] !== undefined) - details += 'Bytes In (downloaded): ' + NumBytesAsDisplayString(r['bytesIn']) + '
'; + details += 'Bytes In (downloaded): ' + + NumBytesAsDisplayString(r['bytesIn']) + '
'; if (r['bytesOut'] !== undefined) - details += 'Bytes Out (uploaded): ' + NumBytesAsDisplayString(r['bytesOut']) + '
'; + details += 'Bytes Out (uploaded): ' + + NumBytesAsDisplayString(r['bytesOut']) + '
'; if (r['custom_rules'] !== undefined) { for (rule in r['custom_rules']) { details += 'Custom Rule - ' + rule + ': ('; - details += r['custom_rules'][rule]['count'] + ' matches) - '; - details += r['custom_rules'][rule]['value'].replace(/>/g, '>').replace(/'; + details += r['custom_rules'][rule]['count'] + + ' matches) - '; + details += r['custom_rules'][rule]['value'].replace(/>/g, + '>').replace(/'; } } - if (r['headers'] !== undefined){ - if (r.headers['request'] !== undefined){ - for (i=0;i'; } } - if (r.headers['response'] !== undefined){ - for (i=0;i'; } } } + return reformatHeaders(responseHeaders); + } + + } + return null; +} + +function SelectRequest(eventName, request) { + var eventNameID = eventName.replace(/ /g, "_"); + initDialog(eventName); + $('#request-dialog' + eventNameID) + .css( + 'top', + $("#request-overlay-" + eventNameID + "-" + request) + .position().top + 20); + $("#dialog-title" + eventNameID).html( + '' + + eventName + ' - Request #' + request + ''); + var details = ''; + var requestHeaders = ''; + var responseHeaders = ''; + $("#response-body" + eventNameID).html(''); + $('#response-body-button' + eventNameID).hide(); + $("#response-image").html(''); + $('#response-image-button').hide(); + try { + if (wptBodyRequest !== undefined) + wptBodyRequest.abort(); + } catch (err) { + } + var wptRequests; + if (eventName != -1) { + wptRequests = wptRequestData[eventName]; + } else { + wptRequests = wptRequestData; + } + if (wptRequests[request - 1] !== undefined) { + var r = wptRequests[request - 1]; if (r['body_url'] !== undefined && r['body_url'].length) { try { - $("#response-body").text('Loading...'); - $('#response-body-button').show(); + $("#response-body" + eventNameID).text('Loading...'); + $('#response-body-button' + eventNameID).show(); wptBodyRequest = new XMLHttpRequest(); wptBodyRequest.open('GET', r['body_url'], true); wptBodyRequest.onreadystatechange = function() { if (wptBodyRequest.readyState == 4) { if (wptBodyRequest.status == 200) { - $("#response-body").text(wptBodyRequest.responseText); + $("#response-body" + eventNameID).text( + wptBodyRequest.responseText); } else { - $("#response-body").text(''); + $("#response-body" + eventNameID).text(''); } } } wptBodyRequest.send(); } catch (err) { } - } else if (r['contentType'] !== undefined && r['contentType'].indexOf('image') >= 0) { - $('#response-body-button').show(); + } else if (r['contentType'] !== undefined + && r['contentType'].indexOf('image') >= 0) { + $('#response-body-button' + eventNameID).show(); if (wptNoLinks) { - $("#response-body").html(''); + $("#response-body" + eventNameID).html( + ''); } else { - $("#response-body").html(''); + $("#response-body" + eventNameID) + .html( + ''); } } } - $("#request-details").html(details); - $("#request-headers").html(requestHeaders); - $("#response-headers").html(responseHeaders); - $('#request-dialog').jqmShow(); + $("#request-details" + eventNameID).html(getRequestDetails(eventName, request, eResultType.DETAILS)); + $("#request-headers" + eventNameID).html(getRequestDetails(eventName, request, eResultType.REQUEST_HEADERS)); + $("#response-headers" + eventNameID).html(getRequestDetails(eventName, request, eResultType.RESPONSE_HEADERS)); + $('#request-dialog' + eventNameID).jqmShow(); // highlight the selected request - for (i=1;i<=wptRequestCount;i++) { + if (eventName != -1) { + var requestCount = wptRequestCount[eventName]; + } else { + var requestCount = wptRequestCount; + } + for (i = 1; i <= requestCount; i++) { if (i == request) - $("#request-overlay-" + i).addClass("selected"); + $("#request-overlay-" + eventNameID + "-" + i).addClass("selected"); else - $("#request-overlay-" + i).removeClass("selected"); + $("#request-overlay-" + eventNameID + "-" + i).removeClass( + "selected"); } } diff --git a/www/waterfall.php b/www/waterfall.php index 19e41c50db..3b438d66a8 100644 --- a/www/waterfall.php +++ b/www/waterfall.php @@ -5,7 +5,14 @@ require_once('page_data.inc'); require_once('waterfall.inc'); -$page_data = loadPageRunData($testPath, $run, $cached); +$eventName = urldecode($_REQUEST["eventName"]); +if(isset($eventName)){ + $pageDataArray = loadPageRunData($testPath, $run, $cached, null, true); + $page_data = $pageDataArray[$eventName]; +} else { + $page_data = loadPageRunData($testPath, $run, $cached); + $eventName = null; +} $is_mime = (bool)@$_REQUEST['mime']; $is_state = (bool)@$_REQUEST['state']; @@ -14,16 +21,16 @@ $rowcount = array_key_exists('rowcount', $_REQUEST) ? $_REQUEST['rowcount'] : 0; // Get all of the requests; +$requests = getRequests($id, $testPath, $run, $cached, + $is_secure, $has_locations, $use_location_check, false, true); $is_secure = false; $has_locations = false; $use_location_check = false; -$requests = getRequests($id, $testPath, $run, $cached, - $is_secure, $has_locations, $use_location_check); if (@$_REQUEST['type'] == 'connection') { $is_state = true; - $rows = GetConnectionRows($requests, $show_labels); + $rows = GetConnectionRows($requests[$eventName], $show_labels); } else { - $rows = GetRequestRows($requests, $use_dots, $show_labels); + $rows = GetRequestRows($requests[$eventName], $use_dots, $show_labels); } $page_events = GetPageEvents($page_data); $bwIn=0; @@ -51,4 +58,4 @@ // Spit the image out to the browser. imagepng($im); imagedestroy($im); -?> +?> \ No newline at end of file diff --git a/www/waterfall_detail.inc b/www/waterfall_detail.inc index 5ba84d5e92..7350c8f37b 100644 --- a/www/waterfall_detail.inc +++ b/www/waterfall_detail.inc @@ -1,6 +1,22 @@ + + + $eventRequests) +{ ?>
- - +
Request Details
+ @@ -24,11 +40,11 @@ - $request) -{ + // loop through all of the requests and spit out a data table + foreach($eventRequests as $reqNum => $request) + { if($request) { echo ''; @@ -156,97 +172,52 @@ foreach($requests as $reqNum => $request) echo ''; } -} -?> - -
+ +

+ Request Details - +

+ Back to Quicklinks +
#
+ } + ?> + + +
+
+
+ *This product includes GeoLite data created by MaxMind, available from http://maxmind.com/.

'; ?>

- -'; - if (array_key_exists('testinfo', $test) && array_key_exists('testerDNS', $test['testinfo']) && strlen($test['testinfo']['testerDNS'])) - echo "

Test Machine DNS Server(s): {$test['testinfo']['testerDNS']}

\n"; - if (isset($requests) && - is_array($requests) && - count($requests) && - array_key_exists(0, $requests) && - array_key_exists('headers', $requests[0])) { - echo '

Request Headers

'; - echo '

+ Expand All

'; - foreach($requests as $reqNum => $request) { - if($request) { - $requestNum = $reqNum + 1; - echo "

"; - echo "+ Request $requestNum: " . htmlspecialchars($request['full_url']) . "

"; - echo '
'; - echo "

\n"; - if ($settings['nolinks']) - echo "URL: {$request['full_url']}
\n"; - else - echo "URL: {$request['full_url']}
\n"; - echo "Host: " . htmlspecialchars($request['host']) . "
\n"; - if (array_key_exists('ip_addr', $request) && strlen($request['ip_addr'])) - echo "IP: {$request['ip_addr']}
\n"; - if (array_key_exists('location', $request) && strlen($request['location'])) - echo "Location: " . htmlspecialchars($request['location']) . "
\n"; - echo "Error/Status Code: " . htmlspecialchars($request['responseCode']) . "
\n"; - if (array_key_exists('initiator', $request) && strlen($request['initiator'])) { - echo "Initiated By: " . htmlspecialchars($request['initiator']); - if (array_key_exists('initiator_line', $request) && strlen($request['initiator_line'])) - echo " line " . htmlspecialchars($request['initiator_line']); - if (array_key_exists('initiator_column', $request) && strlen($request['initiator_column'])) - echo " column " . htmlspecialchars($request['initiator_column']); - echo "
\n"; - } - if (array_key_exists('client_port', $request) && intval($request['client_port'])) - echo "Client Port: " . htmlspecialchars($request['client_port']) . "
\n"; - if (array_key_exists('custom_rules', $request)) { - foreach($request['custom_rules'] as $rule_name => &$rule) { - echo "Custom Rule - " . htmlspecialchars($rule_name) . ": (" . htmlspecialchars($rule['count']) . " matches) - " . htmlspecialchars($rule['value']) . "
\n"; - } - } - echo "Start Offset: " . number_format($request['load_start'] / 1000.0, 3) . " s
\n"; - if (array_key_exists('dns_ms', $request) && $request['dns_ms'] > 0) - echo "DNS Lookup: {$request['dns_ms']} ms
\n"; - if (array_key_exists('connect_ms', $request) && $request['connect_ms'] > 0) - echo "Initial Connection: {$request['connect_ms']} ms
\n"; - if (array_key_exists('ttfb_ms', $request) && $request['ttfb_ms'] > 0) - echo "Time to First Byte: {$request['ttfb_ms']} ms
\n"; - if (array_key_exists('download_ms', $request) && $request['download_ms'] > 0) - echo "Content Download: {$request['download_ms']} ms
\n"; - echo "Bytes In (downloaded): " . number_format($request['bytesIn'] / 1024.0, 1) . " KB
\n"; - echo "Bytes Out (uploaded): " . number_format($request['bytesOut'] / 1024.0, 1) . " KB
\n"; - if (array_key_exists('body', $request) && $request['body']) { - $cached = (int)@$_GET["cached"]; - echo "View Response Body
\n"; - } - echo "

"; - if (array_key_exists('headers', $request)) { - if (array_key_exists('request', $request['headers']) && is_array($request['headers']['request'])) { - echo '

Request Headers:

' . "\n"; - foreach ($request['headers']['request'] as $value) - echo htmlspecialchars($value) . "
\n"; - echo "

"; - } - if (array_key_exists('response', $request['headers']) && is_array($request['headers']['response'])) { - echo '

Response Headers:

' . "\n"; - foreach ($request['headers']['response'] as $value) - echo htmlspecialchars($value) . "
\n"; - echo "

"; - } - } - - echo '
'; // header_details - } - } - } -?> + + $eventRequests){ + echo "

Request Headers - $eventName

Back to Quicklinks

"; + echo '

+ Expand All Requests

'; + foreach($eventRequests as $reqNumber => $reqData){ + echo "

+$eventName - Request #".($reqNumber+1)."

"; + echo '
'; + echo "
"; + echo "

Details

"; + echo "

"; + echo "

Request Headers

"; + echo "

"; + echo "

Response Headers

"; + echo "

"; + echo "
"; + ?> + +
diff --git a/www/work/workdone.php b/www/work/workdone.php index 4e705c417f..90535a7533 100644 --- a/www/work/workdone.php +++ b/www/work/workdone.php @@ -716,45 +716,19 @@ function ProcessUploadedHAR($testPath) function ProcessHARText($testPath, $harIsFromSinglePageLoad) { - $mergedHar = null; + // Read the json HAR file + $rawHar = file_get_contents("{$testPath}/results.har"); - $dir = opendir($testPath); - if( $dir ) - { - while($file = readdir($dir)) - { - if (preg_match("/^(\d+_(Cached_)?)?results?\.har$/", $file)) - { - // Read and parse the json HAR file - $parsedHar = json_decode(file_get_contents("{$testPath}/{$file}"), true); + // Parse the json file + $parsedHar = json_decode($rawHar, true); gz_compress("{$testPath}/{$file}"); unlink("{$testPath}/{$file}"); if (!$parsedHar) { - logMalformedInput("Failed to parse json file '{$file}'"); - continue; - } - - if( $mergedHar === null) - { - $mergedHar = $parsedHar; - } else { - $mergedHar['log']['pages'] = array_merge( - $mergedHar['log']['pages'], $parsedHar['log']['pages']); - $mergedHar['log']['entries'] = array_merge( - $mergedHar['log']['entries'], $parsedHar['log']['entries']); - } - } - } - } - - if( $mergedHar === null) - { - logMalformedInput("Missing result json file"); + logMalformedInput("Failed to parse json file"); return; } - - ProcessHARData($mergedHar, $testPath, $harIsFromSinglePageLoad); + ProcessHARData($parsedHar, $testPath, $harIsFromSinglePageLoad); } /** diff --git a/www/xmlResult.php b/www/xmlResult.php index f555ccfb22..a98c94f221 100644 --- a/www/xmlResult.php +++ b/www/xmlResult.php @@ -3,6 +3,7 @@ //$debug=true; require_once('common.inc'); +require_once('utils.inc'); require_once('page_data.inc'); require_once('testStatus.inc'); require_once('video/visualProgress.inc.php'); @@ -29,6 +30,8 @@ $pageData = loadAllPageData($testPath); + $pageDataArray = loadAllPageData($testPath, null, true); + $msLoad = microtime(true); // if we don't have an url, try to get it from the page results @@ -43,12 +46,21 @@ if( array_key_exists('r', $_REQUEST) && strlen($_REQUEST['r']) ) echo "{$_REQUEST['r']}\n"; echo "\n"; - - // spit out the calculated averages - $fv = null; - $rv = null; - $pageStats = calculatePageStats($pageData, $fv, $rv); - + + $fvArray = array(); + $rvArray = array(); + $pageStatsArray = array(); + foreach($pageDataArray as $eventName => $pageData){ + $pageStatsArray[$eventName] = calculatePageStats($pageData, $fvArray[$eventName], $rvArray[$eventName]); + if(empty($fvArray[$eventName])){ + unset($fvArray[$eventName]); + } + if(empty($rvArray[$eventName])){ + unset($rvArray[$eventName]); + } + } + + echo "$id\n"; if( FRIENDLY_URLS ) echo "http://$host$uri/result/$id/\n"; @@ -89,18 +101,26 @@ } echo "\n"; echo "\n"; - foreach( $fv as $key => $val ) { - $key = preg_replace('/[^a-zA-Z0-9\.\-_]/', '_', $key); - echo "<$key>" . number_format($val,0, '.', '') . "\n"; - } + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + foreach( $fvArray[$eventName] as $key => $val ){ + echo "<$key>" . number_format($val,0, '.', '') . "\n"; + } + echo "\n"; + } echo "\n"; - if( isset($rv) ) + if( !empty($rvArray) ) { echo "\n"; - foreach( $rv as $key => $val ) { - $key = preg_replace('/[^a-zA-Z0-9\.\-_]/', '_', $key); - echo "<$key>" . number_format($val,0, '.', '') . "\n"; - } + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + foreach( $rvArray[$eventName] as $key => $val ){ + echo "<$key>" . number_format($val,0, '.', '') . "\n"; + } + echo ""; + } echo "\n"; } echo "\n"; @@ -124,62 +144,80 @@ // output the median run data $fvMedian = GetMedianRun($pageData, 0, $median_metric); - if( $fvMedian ) + + $fvMedianArray = array(); + foreach($pageDataArray as $eventName => $pageData){ + $fvMedianArray[$eventName] = GetMedianRun($pageData, 0, $median_metric); + } + + if( !empty($fvMedianArray) ) { echo "\n"; echo "\n"; + + foreach($pageDataArray as $eventName => $pageData){ + $fvMedian = $fvMedianArray[$eventName]; + + echo ""; + echo "".$eventName. ""; echo "$fvMedian\n"; foreach( $pageData[$fvMedian][0] as $key => $val ) { $key = preg_replace('/[^a-zA-Z0-9\.\-_]/', '_', $key); - echo "<$key>" . xml_entities($val) . "\n"; + echo "<$key>" . xml_entities($val) . "\n"; } if (gz_is_file("$testPath/{$fvMedian}_pagespeed.txt")) { - if( $pagespeed ) - { - $score = GetPageSpeedScore("$testPath/{$fvMedian}_pagespeed.txt"); - if( strlen($score) ) - echo "$score\n"; - } - if( FRIENDLY_URLS ) - echo "http://$host$uri/result/$id/{$fvMedian}_pagespeed.txt\n"; - else - echo "http://$host$uri//getgzip.php?test=$id&file={$fvMedian}_pagespeed.txt\n"; + if( $pagespeed ) + { + $score = GetPageSpeedScore("$testPath/{$fvMedian}_pagespeed.txt"); + if( strlen($score) ) + echo "$score\n"; + } + if( FRIENDLY_URLS ) + echo "http://$host$uri/result/$id/{$fvMedian}_pagespeed.txt\n"; + else + echo "http://$host$uri//getgzip.php?test=$id&file={$fvMedian}_pagespeed.txt\n"; } xmlDomains($id, $testPath, $fvMedian, 0); xmlBreakdown($id, $testPath, $fvMedian, 0); xmlRequests($id, $testPath, $fvMedian, 0); - StatusMessages($id, $testPath, $fvMedian, 0); - ConsoleLog($id, $testPath, $fvMedian, 0); + echo ""; + } echo "\n"; - - if( isset($rv) ) + + if( !empty($rvArray) ) { - $rvMedian = GetMedianRun($pageData, 1, $median_metric); - if($rvMedian) + $rvMedianArray = array(); + foreach($pageDataArray as $eventName => $pageData){ + $rvMedianArray[$eventName] = GetMedianRun($pageData, 1, $median_metric); + } + if(!empty($rvMedianArray)) { echo "\n"; + foreach($pageDataArray as $eventName => $pageData){ + $rvMedian = $rvMedianArray[$eventName]; + + echo ""; + echo "".$eventName. ""; echo "$rvMedian\n"; foreach( $pageData[$rvMedian][1] as $key => $val ) { $key = preg_replace('/[^a-zA-Z0-9\.\-_]/', '_', $key); - echo "<$key>" . xml_entities($val) . "\n"; - } - if (gz_is_file("$testPath/{$fvMedian}_Cached_pagespeed.txt")) { - if( $pagespeed ) - { - $score = GetPageSpeedScore("$testPath/{$rvMedian}_Cached_pagespeed.txt"); - if( strlen($score) ) - echo "$score\n"; - } - if( FRIENDLY_URLS ) - echo "http://$host$uri/result/$id/{$rvMedian}_Cached_pagespeed.txt\n"; - else - echo "http://$host$uri//getgzip.php?test=$id&file={$rvMedian}_Cached_pagespeed.txt\n"; + echo "<$key>" . xml_entities($val) . "\n"; + if( $pagespeed ) + { + $score = GetPageSpeedScore("$testPath/{$rvMedian}_Cached_pagespeed.txt"); + if( strlen($score) ) + echo "$score\n"; + } + if( FRIENDLY_URLS ) + echo "http://$host$uri/result/$id/{$rvMedian}_Cached_pagespeed.txt\n"; + else + echo "http://$host$uri//getgzip.php?test=$id&file={$rvMedian}_Cached_pagespeed.txt\n"; } xmlDomains($id, $testPath, $fvMedian, 1); xmlBreakdown($id, $testPath, $fvMedian, 1); xmlRequests($id, $testPath, $fvMedian, 1); - StatusMessages($id, $testPath, $fvMedian, 1); - ConsoleLog($id, $testPath, $fvMedian, 1); + echo ""; + } echo "\n"; } } @@ -199,9 +237,12 @@ { echo "\n"; echo "\n"; - foreach( $pageData[$i][0] as $key => $val ) { - $key = preg_replace('/[^a-zA-Z0-9\.\-_]/', '_', $key); - echo "<$key>" . xml_entities($val) . "\n"; + + foreach($pageDataArray as $eventName => $pageData){ + echo ""; + echo "".$eventName. ""; + foreach( $pageData[$i][0] as $key => $val ) + echo "<$key>" . xml_entities($val) . "\n"; } if( $pagespeed ) { @@ -209,6 +250,8 @@ if( strlen($score) ) echo "$score\n"; } + echo ""; + } echo "\n"; // links to the relevant pages @@ -230,48 +273,102 @@ echo "http://$host$uri/screen_shot.php?test=$id&run=$i\n"; } echo "\n"; - + // urls for the relevant images echo "\n"; - echo "http://$host$uri/result/$id/{$i}_waterfall_thumb.png\n"; - echo "http://$host$uri/result/$id/{$i}_optimization_thumb.png\n"; - if( is_file("$testPath/{$i}_screen.jpg") ) - echo "http://$host$uri/result/$id/{$i}_screen_thumb.jpg\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri/result/$id/{$i}/".urlencode($eventName)."/waterfall_thumb.png"; + echo ""; + } + echo "\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri/result/$id/{$i}/".urlencode($eventName)."/optimization_thumb.png"; + echo ""; + } + echo "\n"; + echo ""; + $pageRunData = loadPageRunData($testPath, $i, 0, null, true); + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri/result/$id/{$i}_".$pageRunData[$eventName]["pageNumber"]."_screen_thumb.jpg"; + echo ""; + } + echo "\n"; echo "\n"; echo "\n"; - echo "http://$host$uri$path/{$i}_waterfall.png\n"; - echo "http://$host$uri$path/{$i}_connection.png\n"; - echo "http://$host$uri$path/{$i}_optimization.png\n"; - if( is_file("$testPath/{$i}_screen.jpg") ) - echo "http://$host$uri$path/{$i}_screen.jpg\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_".urlencode($eventName)."_waterfall.png"; + echo ""; + } + echo "\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_".urlencode($eventName)."_connection.png"; + echo ""; + } + echo "\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_".urlencode($eventName)."_optimization.png"; + echo ""; + } + echo "\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_".$pageRunData[$eventName]["pageNumber"]."_screen.jpg"; + echo ""; + } + echo "\n"; if( is_file("$testPath/{$i}_screen.png") ) echo "http://$host$uri$path/{$i}_screen.png\n"; echo "\n"; // raw results echo ""; - if (gz_is_file("$testPath/{$i}_report.txt")) - echo "http://$host$uri$path/{$i}_report.txt\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_".$pageRunData[$eventName]["pageNumber"]."_report.txt"; + echo ""; + } + echo "\n"; if (is_file("$testPath/{$i}_bodies.zip")) echo "http://$host$uri$path/{$i}_bodies.zip\n"; if (gz_is_file("$testPath/{$i}_IEWPG.txt")) - echo "http://$host$uri$path/{$i}_IEWPG.txt\n"; + echo "http://$host$uri$path/{$i}_IEWPG.txt\n"; if (gz_is_file("$testPath/{$i}_IEWTR.txt")) - echo "http://$host$uri$path/{$i}_IEWTR.txt\n"; + echo "http://$host$uri$path/{$i}_IEWTR.txt\n"; if (gz_is_file("$testPath/{$i}_progress.csv")) - echo "http://$host$uri$path/{$i}_progress.csv\n"; + echo "http://$host$uri$path/{$i}_progress.csv\n"; if (gz_is_file("$testPath/{$i}_pagespeed.txt")) - echo "http://$host$uri/result/$id/{$i}_pagespeed.txt\n"; - echo "\n"; - + echo "http://$host$uri/result/$id/{$i}_pagespeed.txt\n"; + echo "\n"; + // video frames $startOffset = array_key_exists('testStartOffset', $pageData[$i][0]) ? intval(round($pageData[$i][0]['testStartOffset'])) : 0; $progress = GetVisualProgress($testPath, $i, 0, null, null, $startOffset); if (array_key_exists('frames', $progress) && is_array($progress['frames']) && count($progress['frames'])) { - echo "\n"; + echo "\n"; foreach($progress['frames'] as $ms => $frame) { - echo "\n"; + echo "\n"; echo "\n"; echo "http://$host$uri$path/video_{$i}/{$frame['file']}\n"; echo "{$frame['progress']}\n"; @@ -288,7 +385,7 @@ foreach ($progress['DevTools']['processing'] as $key => $value) echo "<$key>$value\n"; echo "\n"; - } + } if (array_key_exists('VisualProgress', $progress['DevTools'])) { echo "\n"; foreach ($progress['DevTools']['VisualProgress'] as $key => $value) @@ -310,9 +407,11 @@ { echo "\n"; echo "\n"; - foreach( $pageData[$i][1] as $key => $val ) { - $key = preg_replace('/[^a-zA-Z0-9\.\-_]/', '_', $key); - echo "<$key>" . xml_entities($val) . "\n"; + foreach($pageDataArray as $eventName => $pageData){ + echo ""; + echo "".$eventName. ""; + foreach( $pageData[$i][1] as $key => $val ) + echo "<$key>" . xml_entities($val) . "\n"; } if( $pagespeed ) { @@ -320,6 +419,8 @@ if( strlen($score) ) echo "$score\n"; } + echo ""; + } echo "\n"; // links to the relevant pages @@ -331,48 +432,102 @@ echo "http://$host$uri/result/$id/$i/domains/\n"; echo "http://$host$uri/result/$id/$i/screen_shot/cached/\n"; echo "\n"; - + // urls for the relevant images echo "\n"; - echo "http://$host$uri/result/$id/{$i}_Cached_waterfall_thumb.png\n"; - echo "http://$host$uri/result/$id/{$i}_Cached_optimization_thumb.png\n"; - if( is_file("$testPath/{$i}_Cached_screen.jpg") ) - echo "http://$host$uri/result/$id/{$i}_Cached_screen_thumb.jpg\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri/result/$id/{$i}/".urlencode($eventName)."/Cached_waterfall_thumb.png"; + echo ""; + } + echo "\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri/result/$id/{$i}/".urlencode($eventName)."/Cached_optimization_thumb.png"; + echo ""; + } + echo "\n"; + $pageRunDataCached = loadPageRunData($testPath, $i, 1, null, true); + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri/result/$id/{$i}_Cached_".$pageRunDataCached[$eventName]["pageNumber"]."_screen_thumb.jpg"; + echo ""; + } + echo "\n"; echo "\n"; echo "\n"; - echo "http://$host$uri$path/{$i}_Cached_waterfall.png\n"; - echo "http://$host$uri$path/{$i}_Cached_connection.png\n"; - echo "http://$host$uri$path/{$i}_Cached_optimization.png\n"; - if( is_file("$testPath/{$i}_Cached_screen.jpg") ) - echo "http://$host$uri$path/{$i}_Cached_screen.jpg\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_Cached_".urlencode($eventName)."_waterfall.png"; + echo ""; + } + echo "\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_Cached_".urlencode($eventName)."_connection.png"; + echo ""; + } + echo "\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_Cached_".urlencode($eventName)."_optimization.png"; + echo ""; + } + echo "\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_Cached_".$pageRunDataCached[$eventName]["pageNumber"]."_screen.jpg"; + echo ""; + } + echo "\n"; if( is_file("$testPath/{$i}_Cached_screen.png") ) echo "http://$host$uri$path/{$i}_Cached_screen.png\n"; echo "\n"; // raw results echo "\n"; - if (gz_is_file("$testPath/{$i}_Cached_report.txt")) - echo "http://$host$uri$path/{$i}_Cached_report.txt\n"; + echo ""; + foreach(array_keys($pageDataArray) as $eventName){ + echo ""; + echo "".$eventName. ""; + echo "http://$host$uri$path/{$i}_Cached_".$pageRunDataCached[$eventName]["pageNumber"]."_report.txt"; + echo ""; + } + echo "\n"; if (is_file("$testPath/{$i}_Cached_bodies.zip")) echo "http://$host$uri$path/{$i}_Cached_bodies.zip\n"; if (gz_is_file("$testPath/{$i}_Cached_IEWPG.txt")) - echo "http://$host$uri$path/{$i}_Cached_IEWPG.txt\n"; + echo "http://$host$uri$path/{$i}_Cached_IEWPG.txt\n"; if (gz_is_file("$testPath/{$i}_Cached_IEWTR.txt")) - echo "http://$host$uri$path/{$i}_Cached_IEWTR.txt\n"; + echo "http://$host$uri$path/{$i}_Cached_IEWTR.txt\n"; if (gz_is_file("$testPath/{$i}_Cached_progress.csv")) - echo "http://$host$uri$path/{$i}_Cached_progress.csv\n"; + echo "http://$host$uri$path/{$i}_Cached_progress.csv\n"; if (gz_is_file("$testPath/{$i}_Cached_pagespeed.txt")) - echo "http://$host$uri/result/$id/{$i}_Cached_pagespeed.txt\n"; + echo "http://$host$uri/result/$id/{$i}_Cached_pagespeed.txt\n"; echo "\n"; - + // video frames $startOffset = array_key_exists('testStartOffset', $pageData[$i][1]) ? intval(round($pageData[$i][1]['testStartOffset'])) : 0; $progress = GetVisualProgress($testPath, $i, 1, null, null, $startOffset); if (array_key_exists('frames', $progress) && is_array($progress['frames']) && count($progress['frames'])) { - echo "\n"; + echo "\n"; foreach($progress['frames'] as $ms => $frame) { - echo "\n"; + echo "\n"; echo "\n"; echo "http://$host$uri$path/video_{$i}_cached/{$frame['file']}\n"; echo "{$frame['progress']}\n"; @@ -390,7 +545,7 @@ echo "<$key>$value\n"; echo "\n"; } - + xmlDomains($id, $testPath, $i, 1); xmlBreakdown($id, $testPath, $i, 1); xmlRequests($id, $testPath, $i, 1); @@ -448,8 +603,8 @@ } /** -* Dump a breakdown of the requests and bytes by domain -*/ + * Dump a breakdown of the requests and bytes by domain + */ function xmlDomains($id, $testPath, $run, $cached) { if (array_key_exists('domains', $_REQUEST) && $_REQUEST['domains']) { echo "\n"; @@ -468,8 +623,8 @@ function xmlDomains($id, $testPath, $run, $cached) { } /** -* Dump a breakdown of the requests and bytes by mime type -*/ + * Dump a breakdown of the requests and bytes by mime type + */ function xmlBreakdown($id, $testPath, $run, $cached) { if (array_key_exists('breakdown', $_REQUEST) && $_REQUEST['breakdown']) { echo "\n"; @@ -488,8 +643,8 @@ function xmlBreakdown($id, $testPath, $run, $cached) { /** -* Dump information about all of the requests -*/ + * Dump information about all of the requests + */ function xmlRequests($id, $testPath, $run, $cached) { if (array_key_exists('requests', $_REQUEST) && $_REQUEST['requests']) { echo "\n"; @@ -500,7 +655,7 @@ function xmlRequests($id, $testPath, $run, $cached) { echo "\n"; foreach ($request as $field => $value) { if (!is_array($value)) - echo "<$field>" . xml_entities($value) . "\n"; + echo "<$field>" . xml_entities($value) . "\n"; } if (array_key_exists('headers', $request) && is_array($request['headers'])) { echo "\n"; @@ -508,8 +663,8 @@ function xmlRequests($id, $testPath, $run, $cached) { echo "\n"; foreach ($request['headers']['request'] as $value) echo "
" . xml_entities($value) . "
\n"; - echo "
\n"; - } + echo "
\n"; + } if (array_key_exists('response', $request['headers']) && is_array($request['headers']['response'])) { echo "\n"; foreach ($request['headers']['response'] as $value) @@ -608,7 +763,7 @@ function BatchResult($id, $testPath) foreach( $legacyData as &$legacyTest ) $tests['urls'][] = array('u' => $legacyTest['url'], 'id' => $legacyTest['id']); } - + if( count($tests['urls']) ) { echo "200"; From a465c762a2cfb4957baa1a634f15ec01bffdce25 Mon Sep 17 00:00:00 2001 From: cws Date: Wed, 13 Nov 2013 10:59:25 +0100 Subject: [PATCH 5/5] Fixed merge bugs and changed default EventName --- agent/wpthook/results.cc | 4 +- www/details.php | 2 +- www/export.php | 12 +- www/page_data.inc | 25 +++- www/pageimages.php | 2 +- www/result.inc | 282 ++++++++++++++++++++------------------- www/utils.inc | 2 +- www/waterfall.js | 17 ++- www/xmlResult.php | 50 ++++--- 9 files changed, 213 insertions(+), 183 deletions(-) diff --git a/agent/wpthook/results.cc b/agent/wpthook/results.cc index b175a4f57b..f1d77081c4 100644 --- a/agent/wpthook/results.cc +++ b/agent/wpthook/results.cc @@ -214,8 +214,8 @@ void Results::SaveStatusMessages(void) { void Results::SaveImages(void) { // save the event-based images CxImage image; - CString page("_"); - page.AppendChar(char(currentPage + '0')); + CString page; + page.Format(_T("_%d"), currentPage); if (_screen_capture.GetImage(CapturedImage::START_RENDER, image)) { SaveImage(image, _file_base + page + IMAGE_START_RENDER, _test._image_quality); diff --git a/www/details.php b/www/details.php index 3d61a73f9c..77c954bce0 100644 --- a/www/details.php +++ b/www/details.php @@ -252,7 +252,7 @@ } if (array_key_exists('domTime', $data) && (float)$data['domTime'] > 0.0 ) echo "" . formatMsInterval($data['domTime'], 3) . "\n"; - if (array_key_exists('domElements', $data) && $data['domElements'] > 0 ) + if (array_key_exists('domElements', $data)) echo "{$data['domElements']}\n"; $resultCode = $data['result']; if(!isset($resultCode) || $resultCode === null || $resultCode === ""){ diff --git a/www/export.php b/www/export.php index 78115ef28f..d7f9b9c99c 100644 --- a/www/export.php +++ b/www/export.php @@ -20,11 +20,11 @@ { $pageData[0] = array(); if( isset($cached) ) - $pageData[$run][$cached] = loadPageRunData($testPath, $run, $cached, null, true); + $pageData = loadPageRunData($testPath, $run, $cached, null, true, true); else { - $pageData[$run][0] = loadPageRunData($testPath, $run, 0, null, true); - $pageData[$run][1] = loadPageRunData($testPath, $run, 1, null, true); + $pageData = loadPageRunData($testPath, $run, 0, null, true, true); + $pageData = loadPageRunData($testPath, $run, 1, null, true, true); } } else @@ -33,12 +33,6 @@ // build up the array $result = BuildResult($pageData); - if (array_key_exists('testinfo', $test) && - !array_key_exists('exported', $test['testinfo'])) { - $test['testinfo']['exported'] = true; - gz_file_put_contents("$testPath/testinfo.json", json_encode($test['testinfo'])); - } - // spit it out as json $filename = ''; if (@strlen($url)) diff --git a/www/page_data.inc b/www/page_data.inc index 68fe5011e4..eca73b2dd5 100644 --- a/www/page_data.inc +++ b/www/page_data.inc @@ -9,6 +9,8 @@ require_once('utils.inc'); * @param mixed $testPath * @param mixed $run * @param mixed $cached + * @param bool $allEvents + * boolean if data for all events shall be used */ function loadAllPageData($testPath, $options = null, $allEvents = false) { @@ -61,8 +63,12 @@ function loadAllPageData($testPath, $options = null, $allEvents = false) * @param mixed $run * @param mixed $fv * @param mixed $rv + * @param bool $allEvents + * boolean if data for all events shall be used + * @param bool $allLevels (only with $allEvents = true) + * boolean if all array levels shall be added (eventName, run and cached) */ - function loadPageRunData($testPath, $run, $cached, $options = null, $allEvents = false) + function loadPageRunData($testPath, $run, $cached, $options = null, $allEvents = false, $allLevels = false) { $ret = null; @@ -137,6 +143,19 @@ function loadAllPageData($testPath, $options = null, $allEvents = false) } } $ret[$eventName] = $data; + } + if($allLevels){ + $tmp = array(); + if($allEvents){ + foreach($ret as $eventName => $data){ + $tmp[$eventName][$run][$cached] = $data; + } + } else { + foreach($ret as $eventName => $data){ + $tmp[$eventName][$run][$cached] = $data; + } + } + $ret = $tmp; } return $ret; } @@ -145,6 +164,10 @@ function loadAllPageData($testPath, $options = null, $allEvents = false) * Load the page data from the specified file * * @param mixed $file + * @param mixed $testPath + * @param mixed $options + * @param bool $allEvents + * boolean if data for all events shall be used */ function loadPageData($file, $testPath, $options = null, $allEvents = false) { diff --git a/www/pageimages.php b/www/pageimages.php index 9e6c47103b..d0241cc931 100644 --- a/www/pageimages.php +++ b/www/pageimages.php @@ -34,7 +34,7 @@

Images are what are currently being served from the given url and may not necessarily match what was loaded at the time of the test.

', 0.0, "float", -1, $fvMedian, 0)) $cols++; if (checkForAllEventNames($pageDataArray, 'domElements', '>', 0, null, -1, $fvMedian, 0)) @@ -230,13 +230,14 @@ $page_description = "Website performance test result$testLabel."; $fvMedian = $fvMedianArray[$eventName]; ?> - \n"; - echo "\n"; - echo "\n"; - if(checkForAllEventNames($pageDataArray, 'SpeedIndex', '>', 0, "int", -1, $fvMedian, 0)) { + \n"; + echo "\n"; + echo "\n"; + if(checkForAllEventNames($pageDataArray, 'SpeedIndex', '>', 0, "int", -1, $fvMedian, 0)) { if(array_key_exists('SpeedIndexCustom', $pageData[$fvMedian][0])) echo "\n"; else @@ -244,7 +245,7 @@ $page_description = "Website performance test result$testLabel."; } elseif(checkForAllEventNames($pageDataArray, 'SpeedIndexDT', '>', 0, "int", -1, $fvMedian, 0)) { echo "\n"; } - if (checkForAllEventNames($pageDataArray, 'domTime', '>', 0.0, "float", -1, $fvMedian, 0)){ + if (checkForAllEventNames($pageDataArray, 'domTime', '>', 0.0, "float", -1, $fvMedian, 0)){ $domTime = number_format($pageData[$fvMedian][0]['domTime'] / 1000.0, 3) . "s"; if($domTime=="0.000s"){ $domTime="-"; @@ -255,13 +256,13 @@ $page_description = "Website performance test result$testLabel."; $domElems = $pageData[$fvMedian][0]['domElements']; echo "\n"; } - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; ?> @@ -297,25 +298,25 @@ $page_description = "Website performance test result$testLabel."; $disp = $pageData[$rvMedian][1]['SpeedIndexDT']; echo "\n"; } - if(checkForAllEventNames($pageDataArray, 'domTime', '>', 0.0, "float", -1, $rvMedian, 1)){ + if(checkForAllEventNames($pageDataArray, 'domTime', '>', 0.0, "float", -1, $rvMedian, 1)){ $domTime = number_format($pageData[$rvMedian][1]['domTime'] / 1000.0, 3) . "s"; if($domTime=="0.000s"){ $domTime="-"; } echo "\n"; } - if (checkForAllEventNames($pageDataArray, 'domElements', '>', 0, null, -1, $rvMedian, 1)){ + if (checkForAllEventNames($pageDataArray, 'domElements', '>', 0, null, -1, $rvMedian, 1)){ $domElems = $pageData[$rvMedian][1]['domElements']; echo "\n"; } - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; ?> @@ -353,33 +354,33 @@ $page_description = "Website performance test result$testLabel."; echo ' (Run ' . $fvMedian . ')'; foreach ( $test['testinfo']['extract_csi'] as $csi_param ) { - if( array_key_exists($csi_param, $fv_params) ) - { - echo ''; - } - else - { - echo ''; - } + if( array_key_exists($csi_param, $fv_params) ) + { + echo ''; + } + else + { + echo ''; + } } // Print the repeat view row. if( $rvMedian ) { - echo ''; - $rv_params = ParseCsiInfo($id, $testPath, $rvMedian, true, true); - echo ''; - } - else - { - echo ''; - } - } + echo ''; + $rv_params = ParseCsiInfo($id, $testPath, $rvMedian, true, true); + echo ''; + } + else + { + echo ''; + } + } } echo ''; ?> @@ -518,13 +519,13 @@ $page_description = "Website performance test result$testLabel."; if ($run == $fvMedian && array_key_exists('end', $_REQUEST)) $testUrl .= "&end={$_REQUEST['end']}"; elseif (FRIENDLY_URLS) - $testUrl = "/result/$id/$run/details/"; - echo ""; - if( FRIENDLY_URLS ) - echo ""; - else - echo "\n"; - if (!isset($test['testinfo']) || !$test['testinfo']['noimages']) { + $testUrl = "/result/$id/$run/details/"; + echo ""; + if( FRIENDLY_URLS ) + echo ""; + else + echo "\n"; + if (!isset($test['testinfo']) || !$test['testinfo']['noimages']) { if( FRIENDLY_URLS ) echo ""; else @@ -547,71 +548,71 @@ $page_description = "Website performance test result$testLabel."; echo ''; } echo ''; - } - foreach($pageDataArray as $eventName => $pageData){ - if( isset($pageData[$run][1]) ) { ?> - - '; - echo ""; - else - echo ""; - - if (!isset($test['testinfo']) || !$test['testinfo']['noimages']) { - if( FRIENDLY_URLS ) - echo ""; - else - echo ""; - } - if ($video) { - echo ''; - } - } else { - echo ""; - } - echo ''; - } + } + foreach($pageDataArray as $eventName => $pageData){ + if( isset($pageData[$run][1]) ) { ?> + + '; + echo ""; + else + echo ""; + + if (!isset($test['testinfo']) || !$test['testinfo']['noimages']) { + if( FRIENDLY_URLS ) + echo ""; + else + echo ""; + } + if ($video) { + echo ''; + } + } else { + echo ""; + } + echo ''; + } } if( $testComplete) { $b = getBreakdown($id, $testPath, $run, 0, $requests); @@ -619,27 +620,28 @@ $page_description = "Website performance test result$testLabel."; $breakdown[] = array('run' => $run, 'data' => $b); } ?> - - - - "; - $extension = 'php'; - if( FRIENDLY_URLS ) - $extension = 'png'; - echo "
(First View) 1) - echo " (Run $fvMedian)"; - echo "" . formatMsInterval($pageData[$fvMedian][0]['loadTime'], 3) . "" . formatMsInterval($pageData[$fvMedian][0]['TTFB'], 3) . "" . formatMsInterval($pageData[$fvMedian][0]['render'], 3) . " (First + View) 1) + echo " (Run $fvMedian)"; + echo "" . formatMsInterval($pageData[$fvMedian][0]['loadTime'], 3) . "" . formatMsInterval($pageData[$fvMedian][0]['TTFB'], 3) . "" . formatMsInterval($pageData[$fvMedian][0]['render'], 3) . "{$pageData[$fvMedian][0]['SpeedIndexCustom']}{$pageData[$fvMedian][0]['SpeedIndexDT']}{$domElems}" . formatMsInterval($pageData[$fvMedian][0]['docTime'], 3) . "" . number_format($pageData[$fvMedian][0]['requestsDoc'],0) . "" . number_format($pageData[$fvMedian][0]['bytesInDoc'] / 1024, 0) . " KB" . formatMsInterval($pageData[$fvMedian][0]['docTime'], 3) . "" . number_format($pageData[$fvMedian][0]['requestsDoc'],0) . "" . number_format($pageData[$fvMedian][0]['bytesInDoc'] / 1024, 0) . " KB" . formatMsInterval($pageData[$fvMedian][0]['fullyLoaded'], 3) . "" . number_format($pageData[$fvMedian][0]['requests'],0) . "" . number_format($pageData[$fvMedian][0]['bytesIn'] / 1024, 0) . " KB" . formatMsInterval($pageData[$fvMedian][0]['fullyLoaded'], 3) . "" . number_format($pageData[$fvMedian][0]['requests'],0) . "" . number_format($pageData[$fvMedian][0]['bytesIn'] / 1024, 0) . " KB
$disp" . $domTime . "{$domElems}" . formatMsInterval($pageData[$rvMedian][1]['docTime'], 3) . "" . number_format($pageData[$rvMedian][1]['requestsDoc'],0) . "" . number_format($pageData[$rvMedian][1]['bytesInDoc'] / 1024, 0) . " KB" . formatMsInterval($pageData[$rvMedian][1]['docTime'], 3) . "" . number_format($pageData[$rvMedian][1]['requestsDoc'],0) . "" . number_format($pageData[$rvMedian][1]['bytesInDoc'] / 1024, 0) . " KB" . formatMsInterval($pageData[$rvMedian][1]['fullyLoaded'], 3) . "" . number_format($pageData[$rvMedian][1]['requests'],0) . "" . number_format($pageData[$rvMedian][1]['bytesIn'] / 1024, 0) . " KB" . formatMsInterval($pageData[$rvMedian][1]['fullyLoaded'], 3) . "" . number_format($pageData[$rvMedian][1]['requests'],0) . "" . number_format($pageData[$rvMedian][1]['bytesIn'] / 1024, 0) . " KB
' . $fv_params[$csi_param] . '' . $fv_params[$csi_param] . '
Repeat View'; - echo ' (Run ' . $rvMedian . ')'; - foreach ( $test['testinfo']['extract_csi'] as $csi_param ) - { - if( array_key_exists($csi_param, $rv_params) ) - { - echo '' . $rv_params[$csi_param] . '
Repeat View'; + echo ' (Run ' . $rvMedian . ')'; + foreach ( $test['testinfo']['extract_csi'] as $csi_param ) + { + if( array_key_exists($csi_param, $rv_params) ) + { + echo '' . $rv_params[$csi_param] . '
Repeat View
- (Error: ' . LookupError($pageData[$run][1]['result']) . ')'; - else if( isset($pageData[$run][1]['loadTime']) ) - echo '
(' . number_format($pageData[$run][1]['loadTime'] / 1000.0, 3) . 's)'; - if( is_file("$testPath/{$run}_Cached_dynaTrace.dtas") ) - { - echo "

\"Download

"; - echo "\"Get"; - } - if( gz_is_file("$testPath/{$run}_Cached.cap") ) - { - $tcpdump_url = "/getgzip.php?test=$id&file={$run}_Cached.cap"; - if( FRIENDLY_URLS ) - $tcpdump_url = "/result/$id/{$run}_Cached.cap"; - echo "

tcpdump"; - if (array_key_exists('tcpdump_view', $settings) && strlen($settings['tcpdump_view'])) { - $view_url = $settings['tcpdump_view'] . urlencode("http://$wpt_host$tcpdump_url"); - echo " - (view)"; - } - } - if( gz_is_file("$testPath/{$run}_Cached_timeline.json") || gz_is_file("$testPath/{$run}_Cached_devtools.json") ) { - echo "

Timeline"; - echo " (view)"; - if (array_key_exists('testinfo', $test) && array_key_exists('timeline', $test['testinfo']) && $test['testinfo']['timeline']) - echo "
Processing Breakdown"; - } - if( gz_is_file("$testPath/{$run}_Cached_netlog.txt") ) { - echo "

Net Log"; - } - if( gz_is_file("$testPath/{$run}_Cached_trace.json") ) { - echo "

Trace"; - } - echo '
"; - if( FRIENDLY_URLS ) - echo "'; - if (is_dir("$testPath/video_{$run}_cached")) { - echo "Filmstrip View
-
"; - echo "Watch Video"; - } else - echo "not available"; - echo '
Repeat View: Test Data for Event Name \"".$eventName."\" missing
Repeat View
+ (Error: ' . LookupError($pageData[$run][1]['result']) . ')'; + else if( isset($pageData[$run][1]['loadTime']) ) + echo '
(' . number_format($pageData[$run][1]['loadTime'] / 1000.0, 3) . 's)'; + if( is_file("$testPath/{$run}_Cached_dynaTrace.dtas") ) + { + echo "

\"Download

"; + echo "\"Get"; + } + if( gz_is_file("$testPath/{$run}_Cached.cap") ) + { + $tcpdump_url = "/getgzip.php?test=$id&file={$run}_Cached.cap"; + if( FRIENDLY_URLS ) + $tcpdump_url = "/result/$id/{$run}_Cached.cap"; + echo "

tcpdump"; + if (array_key_exists('tcpdump_view', $settings) && strlen($settings['tcpdump_view'])) { + $view_url = $settings['tcpdump_view'] . urlencode("http://$wpt_host$tcpdump_url"); + echo " - (view)"; + } + } + if( gz_is_file("$testPath/{$run}_Cached_timeline.json") || gz_is_file("$testPath/{$run}_Cached_devtools.json") ) { + echo "

Timeline"; + echo " (view)"; + if (array_key_exists('testinfo', $test) && array_key_exists('timeline', $test['testinfo']) && $test['testinfo']['timeline']) + echo "
Processing Breakdown"; + } + if( gz_is_file("$testPath/{$run}_Cached_netlog.txt") ) { + echo "

Net Log"; + } + if( gz_is_file("$testPath/{$run}_Cached_trace.json") ) { + echo "

Trace"; + } + echo '
"; + if( FRIENDLY_URLS ) + echo "'; + if (is_dir("$testPath/video_{$run}_cached")) { + echo "Filmstrip View
-
"; + echo "Watch Video"; + } else + echo "not available"; + echo '
Repeat View: Test Data for Event Name \"".$eventName."\" missing
">Content - Breakdown
(Preview for all Events)
"; - echo "
"; - ?> - + + + + ">Content + Breakdown
(Preview for all Events) + "; + $extension = 'php'; + if( FRIENDLY_URLS ) + $extension = 'png'; + echo ""; + echo "
"; + ?> + @@ -647,7 +649,7 @@ $page_description = "Website performance test result$testLabel.";
diff --git a/www/utils.inc b/www/utils.inc index 73c93000ff..2e2ba6c19e 100644 --- a/www/utils.inc +++ b/www/utils.inc @@ -19,7 +19,7 @@ } else { $job = $jobLabel; } - $event = $job . ' ' . ($eventNumber + 1); + $event = $job . ': Event ' . ($eventNumber + 1); // Use eventString if set and not already in use if(trim($eventString) != ""){ diff --git a/www/waterfall.js b/www/waterfall.js index 2b7d8851d4..b4dc0a3070 100644 --- a/www/waterfall.js +++ b/www/waterfall.js @@ -1,7 +1,20 @@ var wptBodyRequest; -function initDialog(eventName) { +/** + * Delivers an ID for the given event name + * (javascript version of method in utilc.inc) + * @param $eventName + * @returns + * $eventName as id + */ +function getEventNameID(eventName){ var eventNameID = eventName.replace(/ /g, "_"); + eventNameID = eventNameID.replace(/[^a-zA-Z0-9_-]/g, ""); + return eventNameID; +} + +function initDialog(eventName) { + var eventNameID = getEventNameID(eventName); var CloseRequestDialog = function(hash) { hash.w.hide(); if (eventName != -1) { @@ -239,7 +252,7 @@ function getRequestDetails(eventName, request, resultType) { } function SelectRequest(eventName, request) { - var eventNameID = eventName.replace(/ /g, "_"); + var eventNameID = getEventNameID(eventName); initDialog(eventName); $('#request-dialog' + eventNameID) .css( diff --git a/www/xmlResult.php b/www/xmlResult.php index a98c94f221..b706c58934 100644 --- a/www/xmlResult.php +++ b/www/xmlResult.php @@ -54,7 +54,7 @@ $pageStatsArray[$eventName] = calculatePageStats($pageData, $fvArray[$eventName], $rvArray[$eventName]); if(empty($fvArray[$eventName])){ unset($fvArray[$eventName]); - } + } if(empty($rvArray[$eventName])){ unset($rvArray[$eventName]); } @@ -172,11 +172,11 @@ if( strlen($score) ) echo "$score\n"; } - if( FRIENDLY_URLS ) - echo "http://$host$uri/result/$id/{$fvMedian}_pagespeed.txt\n"; - else - echo "http://$host$uri//getgzip.php?test=$id&file={$fvMedian}_pagespeed.txt\n"; } + if( FRIENDLY_URLS ) + echo "http://$host$uri/result/$id/{$fvMedian}_pagespeed.txt\n"; + else + echo "http://$host$uri//getgzip.php?test=$id&file={$fvMedian}_pagespeed.txt\n"; xmlDomains($id, $testPath, $fvMedian, 0); xmlBreakdown($id, $testPath, $fvMedian, 0); xmlRequests($id, $testPath, $fvMedian, 0); @@ -208,11 +208,11 @@ if( strlen($score) ) echo "$score\n"; } - if( FRIENDLY_URLS ) - echo "http://$host$uri/result/$id/{$rvMedian}_Cached_pagespeed.txt\n"; - else - echo "http://$host$uri//getgzip.php?test=$id&file={$rvMedian}_Cached_pagespeed.txt\n"; } + if( FRIENDLY_URLS ) + echo "http://$host$uri/result/$id/{$rvMedian}_Cached_pagespeed.txt\n"; + else + echo "http://$host$uri//getgzip.php?test=$id&file={$rvMedian}_Cached_pagespeed.txt\n"; xmlDomains($id, $testPath, $fvMedian, 1); xmlBreakdown($id, $testPath, $fvMedian, 1); xmlRequests($id, $testPath, $fvMedian, 1); @@ -243,13 +243,12 @@ echo "".$eventName. ""; foreach( $pageData[$i][0] as $key => $val ) echo "<$key>" . xml_entities($val) . "\n"; - } - if( $pagespeed ) - { - $score = GetPageSpeedScore("$testPath/{$i}_pagespeed.txt"); - if( strlen($score) ) - echo "$score\n"; - } + if( $pagespeed ) + { + $score = GetPageSpeedScore("$testPath/{$i}_pagespeed.txt"); + if( strlen($score) ) + echo "$score\n"; + } echo ""; } echo "\n"; @@ -385,7 +384,7 @@ foreach ($progress['DevTools']['processing'] as $key => $value) echo "<$key>$value\n"; echo "\n"; - } + } if (array_key_exists('VisualProgress', $progress['DevTools'])) { echo "\n"; foreach ($progress['DevTools']['VisualProgress'] as $key => $value) @@ -412,15 +411,14 @@ echo "".$eventName. ""; foreach( $pageData[$i][1] as $key => $val ) echo "<$key>" . xml_entities($val) . "\n"; - } - if( $pagespeed ) - { - $score = GetPageSpeedScore("$testPath/{$i}_Cached_pagespeed.txt"); - if( strlen($score) ) - echo "$score\n"; - } - echo ""; - } + if( $pagespeed ) + { + $score = GetPageSpeedScore("$testPath/{$i}_Cached_pagespeed.txt"); + if( strlen($score) ) + echo "$score\n"; + } + echo ""; + } echo "\n"; // links to the relevant pages