Forked from ebidel/polymer-perf-bookmarklet.js
Last active
September 8, 2015 16:04
-
-
Save addyosmani/d437f9679269f946b4d8 to your computer and use it in GitHub Desktop.
Revisions
-
ebidel revised this gist
Sep 4, 2015 . 2 changed files with 9 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ javascript:(function(){(function printStats(){var loadTimes=window.chrome.loadTimes();firstPaint=loadTimes.firstPaintTime*1000;firstPaintTime=firstPaint-(loadTimes.startLoadTime*1000);console.info('First paint took',firstPaintTime,'ms');console.info('Load took',performance.timing.loadEventStart-performance.timing.navigationStart,'ms');var instances=0;if(parseFloat(Polymer.version)<1){instances=[].slice.call(document.querySelectorAll('html /deep/ *')).filter(function(el){return el.localName.indexOf('-')!=-1||el.getAttribute('is');}).length;}else{instances=Polymer.telemetry.instanceCount;}console.info('Custom element instances:',instances);var reflectCount=0;if(Polymer.telemetry){console.info('=== Properties set to reflectToAttribute ===');Polymer.telemetry.registrations.forEach(function(el){for(var prop in el.properties){if(el.properties[prop].reflectToAttribute){console.log(el.is+'.'+prop);reflectCount++;}}});}else{console.info('=== Properties set to reflect ===');Polymer.elements.forEach(function(el){for(var prop in el.prototype.publish){var propVal=el.prototype.publish[prop];if(propVal&&propVal.reflect){console.log(el.name+'.'+prop);reflectCount++;}}});}console.info('Total properties set to reflectToAttribute:',reflectCount);var imports=document.querySelectorAll('link[rel="import"]');var table=[];var totalDuration=0;console.info('=== HTML Imports load times ===');[].forEach.call(imports,function(link){var entries=performance.getEntriesByName(link.href);entries.forEach(function(e){table.push({url:e.name,ms:e.duration});totalDuration+=e.duration;});});console.log(imports.length+' imports loaded from the main page. Total time: '+totalDuration+'ms');console.table(table);})();})(); 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 charactersOriginal file line number Diff line number Diff line change @@ -43,16 +43,21 @@ } }); } console.info('Total properties set to reflectToAttribute:', reflectCount); // Main page imports perf. var imports = document.querySelectorAll('link[rel="import"]'); var table = []; var totalDuration = 0; console.info('=== HTML Imports load times ==='); [].forEach.call(imports, function(link) { var entries = performance.getEntriesByName(link.href); entries.forEach(function(e) { table.push({url: e.name, ms: e.duration}); totalDuration += e.duration; }); }); console.log(imports.length + ' imports loaded from the main page. Total time: ' + totalDuration + 'ms'); console.table(table); })(); -
ebidel renamed this gist
Sep 1, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ebidel renamed this gist
Sep 1, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ebidel renamed this gist
Sep 1, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ebidel created this gist
Sep 1, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ javascript:(function(){(function printStats(){var loadTimes=window.chrome.loadTimes();firstPaint=loadTimes.firstPaintTime*1000;firstPaintTime=firstPaint-(loadTimes.startLoadTime*1000);console.info('First paint took',firstPaintTime,'ms');console.info('Load took',performance.timing.loadEventStart-performance.timing.navigationStart,'ms');var instances=0;if(parseFloat(Polymer.version)<1){instances=[].slice.call(document.querySelectorAll('html /deep/ *')).filter(function(el){return el.localName.indexOf('-')!=-1||el.getAttribute('is');}).length;}else{instances=Polymer.telemetry.instanceCount;}console.info('Custom element instances:',instances);var reflectCount=0;if(Polymer.telemetry){console.info('=== Properties set to reflectToAttribute ===');Polymer.telemetry.registrations.forEach(function(el){for(var prop in el.properties){if(el.properties[prop].reflectToAttribute){console.log(el.is+'.'+prop);reflectCount++;}}});}else{console.info('=== Properties set to reflect ===');Polymer.elements.forEach(function(el){for(var prop in el.prototype.publish){var propVal=el.prototype.publish[prop];if(propVal&&propVal.reflect){console.log(el.name+'.'+prop);reflectCount++;}}});}console.info('Total properties set to reflectToAttribute',reflectCount);var imports=document.querySelectorAll('link[rel="import"]');[].forEach.call(imports,function(link){var entries=performance.getEntriesByName(link.href);console.info('=== HTML Imports perf ===');entries.forEach(function(e){console.info(e.name,'took',e.duration,'ms');});});})();})(); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ (function printStats() { // First paint var loadTimes = window.chrome.loadTimes(); firstPaint = loadTimes.firstPaintTime * 1000; firstPaintTime = firstPaint - (loadTimes.startLoadTime * 1000); console.info('First paint took', firstPaintTime, 'ms'); // Page load. console.info('Load took', performance.timing.loadEventStart - performance.timing.navigationStart, 'ms'); // # of custom element instances var instances = 0; if (parseFloat(Polymer.version) < 1) { // Polymer 0.5. instances = [].slice.call(document.querySelectorAll('html /deep/ *')).filter(function(el) { return el.localName.indexOf('-') != -1 || el.getAttribute('is'); }).length; } else { instances = Polymer.telemetry.instanceCount; } console.info('Custom element instances:', instances); // Properties being reflected to attributes. var reflectCount = 0; if (Polymer.telemetry) { console.info('=== Properties set to reflectToAttribute ==='); Polymer.telemetry.registrations.forEach(function(el) { for (var prop in el.properties) { if (el.properties[prop].reflectToAttribute) { console.log(el.is + '.' + prop); reflectCount++; } } }); } else { // 0.5 code console.info('=== Properties set to reflect ==='); Polymer.elements.forEach(function(el) { for (var prop in el.prototype.publish) { var propVal = el.prototype.publish[prop]; if (propVal && propVal.reflect) { console.log(el.name + '.' + prop); reflectCount++; } } }); } console.info('Total properties set to reflectToAttribute', reflectCount); // Main page imports perf. var imports = document.querySelectorAll('link[rel="import"]'); [].forEach.call(imports, function(link) { var entries = performance.getEntriesByName(link.href); console.info('=== HTML Imports perf ==='); entries.forEach(function(e) { console.info(e.name, 'took', e.duration, 'ms'); }); }); })();