Skip to content

Instantly share code, notes, and snippets.

@stramel
Last active March 7, 2018 23:27
Show Gist options
  • Save stramel/82509631e3e187760d4eb916f1ec787a to your computer and use it in GitHub Desktop.
Save stramel/82509631e3e187760d4eb916f1ec787a to your computer and use it in GitHub Desktop.
Profiling Lazy Imports vs importHref on PSK

Profiling of lazy-imports vs importHref

Setup

System Specs

  • CPU: Intel Core i5
  • Memory: 16Gb
  • OS: Windows 10
  • Polymer CLI: 1.6.0
  • Chrome: 64.0.3282.186 (32-bit)

Branches used

  • importHref: master code
  • lazy-imports: ms/2.0-lazy-imports code
  • Modified lazy-imports: ms/refactoring code

Building & Serving

polymer build && polymer serve build/es6-bundled/

Results

Lighthouse Results

These results were generated using Lighthouse from the Audits tab in Chrome DevTools.

Method Run 1 (ms) Run 2 (ms) Run 3 (ms) Run Avg (ms) Avg Score
importHref w/ async: true (Default) 3890 3640 3720 3750 78.33
__importLazyGroup w/ async: false (Default) 4100 4180 4220 4166.66 74.66
importHref w/ async: false 5280 4380 4360 4673.33 69.33
__importLazyGroup w/ async: true 3640 3490 3580 3570 80
Modified __importLazyGroup w/ async: false 4510 4190 4170 4290 73.33
Modified __importLazyGroup w/ async: true 3670 3690 3610 3656.66 79.66

These test results represent the initial page load. The next sections will cover post initial load and navigating to pages already loaded.

Loading additional pages

These results were made analyzing function calls in Chrome DevTools Performance tab with a RAW polymer serve. I measured the total time taken in _pageChanged

Method 1 2 3 4 5 6 7 8 9 10 Call Avg (ms)
importHref w/ async: true 1.14 14.67 11.34 12.38 .58 8.76 .83 11.81 11.37 .62 7.35
__importLazyGroup w/ async: true 9.11 10.63 .95 10.74 .27 9.36 .41 14.72 10.2 12.16 8.929
Modified __importLazyGroup w/ async: true .6 4.05 .64 6.48 .59 .59 10.19 7.28 .58 1.25 3.225

Navigating to existing pages

Measuring repeated calls to import pages that have already been imported. Unfortunately, I couldn't consistently get the _pageChanged function call in the Performance tab. I was however able to more consistently get it to show up when using importHref which generally took ~20-28ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment