sitespeedio / sitespeed.io

sitespeed.io is an open-source tool for comprehensive web performance analysis, enabling you to test, monitor, and optimize your website’s speed using real browsers in various environments.
https://www.sitespeed.io/
MIT License
4.75k stars 602 forks source link

[Question] Understanding results with --preScript and --preURL parameters #2004

Closed abhinavn closed 6 years ago

abhinavn commented 6 years ago

I am testing URLs which are behind login authentication, i use --prescript.

docker run --shm-size=2g --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:6.5.4 --preScript login.js tools/home.txt --preURL https://dc.stage.acrobat.com/ --browsertime.pageCompleteCheck 'return (function() {try { return (Date.now() - window.performance.timing.loadEventEnd) > 5000;} catch(e) {} return true;})()' --browsertime.viewPort 1920x1080 --browsertime.cacheClearRaw --browsertime.chrome.collectTracingEvents --speedIndex --video

screen shot 2018-04-27 at 3 37 00 pm

docker run --shm-size=2g --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:6.5.4 --preScript login.js tools/home.txt --browsertime.pageCompleteCheck 'return (function() {try { return (Date.now() - window.performance.timing.loadEventEnd) > 5000;} catch(e) {} return true;})()' --browsertime.viewPort 1920x1080 --browsertime.cacheClearRaw --browsertime.chrome.collectTracingEvents --speedIndex --video

screen shot 2018-04-27 at 3 37 13 pm

If you notice above, there is difference when I use preURL in first screenshot and second screenshot without preURL, but the firstVisual Change metrics are different too

Questions

My goal is to measure page load times with primed cached, what is the suggested approach?

soulgalore commented 6 years ago

Hi @abhinavn let me update the documentation so this is easier to understand. It work like this: When you run as default the cache is cleared between runs. If you test https://www.sitespeed.io 5 runs, the browser cache is cleared between each run, so the browser has no cached assets between the runs.

When you run --preURL the browser starts, then access the preURL and then the URL you want to test within the same session and not clearing the cache. Use this if you want to measure more realistic metrics if your user first hit your start page and then another page (with responses in the cache).

preScript is the same behavior, we don't clear the cache between preScript and the URL you want to test.

If I use preScript is the cache already loaded? The subsequent URL launched is measured with cache?

Yes.

Why is there difference in fisrtVisualChange with and without --preURL?

Assets are cached and you can have HTTP connections already open depending how long time you wait between the first URL and the next.

Why is compress assets advice so different?

If the assets is on disk (in the cache) it doesn't matter if it was sent compressed over the wire the first time or not.

Hope that makes thing clearer.

Best Peter

abhinavn commented 6 years ago

@soulgalore - You rock! Thanks for detailed explanation. It helps.