startup.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. (function(Perf) {
  2. var $listPage = $( "#list-page" ), firstCounter = 0;
  3. Perf.setCurrentRev();
  4. Perf.pageLoadStart = Date.now();
  5. $( document ).bind( "mobileinit", function() {
  6. Perf.pageProcessingStart = Date.now();
  7. });
  8. $listPage.live( "pagebeforecreate", function() {
  9. if( firstCounter == 0 ) {
  10. Perf.pageCreateStart = Date.now();
  11. firstCounter++;
  12. }
  13. });
  14. $listPage.live( "pagecreate", function( event ) {
  15. if( event.target !== $("#list-page")[0] ){
  16. return;
  17. }
  18. Perf.pageEnhanceStart = Date.now();
  19. });
  20. $listPage.live( "pageinit", function( event ) {
  21. // if a child page init is fired ignore it, we only
  22. // want the top level page init event
  23. if( event.target !== $("#list-page")[0] ){
  24. return;
  25. }
  26. Perf.pageLoadEnd = Date.now();
  27. // report the time taken for a full app boot includes the time for
  28. // the jquery mobile js to load
  29. Perf.report({
  30. datapoint: "fullboot",
  31. value: Perf.pageLoadEnd - Perf.pageLoadStart
  32. });
  33. // report the time taken for the first page to be enhanced
  34. // pagecreate -> pageinit
  35. Perf.report({
  36. datapoint: "enhancement",
  37. value: Perf.pageLoadEnd - Perf.pageEnhanceStart
  38. });
  39. // report the time taken for the page to process. does *not*
  40. // inclue the load time for js
  41. // mobileinit -> pageinit
  42. Perf.report({
  43. datapoint: "pageprocessing",
  44. value: Perf.pageLoadEnd - Perf.pageProcessingStart
  45. });
  46. // record the time taken to load and enhance the page
  47. // start polling for a new revision
  48. Perf.report({
  49. datapoint: "pageload",
  50. value: Perf.pageCreateStart - Perf.pageLoadStart,
  51. after: function() {
  52. Perf.poll();
  53. }
  54. });
  55. });
  56. })(window.Perf);