Created
July 1, 2016 09:29
-
-
Save yabusaio/c0d4f8045751d74d271eaab1bfe882a5 to your computer and use it in GitHub Desktop.
performance 包含页面加载到执行完成的整个生命周期中不同执行步骤的执行时间
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function _performance(){ | |
| var REPORT_URL = "xxxx/cgi?perf="; | |
| var perf = (window.webkitPerformance ? window.webkitPerformance : window.msPerformance ), | |
| points = ['navigationStart','unloadEventStart','unloadEventEnd','redirectStart','redirectEnd','fetchStart','domainLookupStart','connectStart','requestStart','responseStart','responseEnd','domLoading','domInteractive','domContentLoadedEventEnd','domComplete','loadEventStart','loadEventEnd']; | |
| var timing = pref.timing; | |
| perf = perf ? perf : window.performance; | |
| if( perf && timing ) { | |
| var arr = []; | |
| var navigationStart = timing[points[0]]; | |
| for(var i=0,l=points.length;i<l;i++){ | |
| arr[i] = timing[points[i]] - navigationStart; | |
| } | |
| var url = REPORT_URL + arr.join("-"); | |
| var img = new Image; | |
| img.onload = img.onerror = function(){ | |
| img=null; | |
| } | |
| img.src = url; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment