Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LDNWebPerf May 2016 - Andy Davies

LDNWebPerf May 2016 - Andy Davies

More Decks by London Web Performance Group

Other Decks in Technology

Transcript

  1. @patmeenan ▪ Web performance – Browser and OS activity ▪

    Open source – Patrick Meenan – AOL 2008 ▪ webpagetest.org – Public instance – Global infrastructure
  2. http://usingwpt.com Aimed at Novices and Power Users Includes: Basics Getting

    started, running tests, understanding waterfall charts and the metrics WebPageTest captures Intermediate Picking the right test parameters, scripting multi-page tests and using your existing analytics data to help the decisions Advanced Using the API, integrating WebPageTest into build and CI processes, and setting up your own private instances
  3. How it works (simplified) Poll for work, measure load and

    return results to server Load page / pages
  4. Create pcap for Wireshark etc. Inject custom headers e.g. Akamai

    debug Make tests run for longer e.g catch slow XHR requests http://man.gl/1UxalBe
  5. Emulate mobile browsers Capture Chrome debugging info from remote browser

    Add command-line options - great for comparing HTTP/1.1 vs HTTP/2 Chrome only options http://man.gl/1UxetBe
  6. Convert the list of domains into a space separated list

    (copy ‘n’ paste plus text editor) http://man.gl/1OcK1FM
  7. curl 'http://www.webpagetest.org/domains.php? test=160429_5W_cbb3cdebf94050c7b08e49e596d89103&run=1&cached=0& f=json' | jq -rj '.domains.firstView[].domain + "

    "' | pbcopy Or grab domains in json and pipe through jq Copy to clipboard Extract domain names Get domain breakdown in JSON
  8. Paste list of domains / urls to remove (Don’t forget

    to remove the site you’re testing from the block list)
  9. But switching to Firefox With a bit of patience, and

    by adjusting the block list we can get there http://man.gl/1nLwRZe
  10. Results page only - http://man.gl/1PEEwn4 Search and results page -

    http://man.gl/1PEEBak Waterfall for results page only Searching Google
  11. JavaScript to the Rescue! http://man.gl/1PEGQdL logData 0 navigate http://www.bbc.co.uk/ logData

    1 execAndWait document.querySelector('.orb-nav-newsdotcom a').click(); execAndWait - execute JS and wait for browser to complete activity exec - execute JS and don’t wait
  12. JQuery FTW! Honestly! logData 0 navigate http://www.thetrainline.com exec document.getElementById('originStation').value='Cheltenham'; exec

    $('#originStation').keydown(); exec document.querySelectorAll('#originStation + div + ul > li > a')[0].click(); Use JQuery’s keydown method JQuery must be already on the page
  13. Debugging scripts can be hard! logData 0 navigate http://www.thetrainline.com exec

    document.getElementById('originStation').value='Cheltenham'; exec $('#originStation').keydown(); exec document.querySelectorAll('#originStation + div + ul > li > a')[0].click(); exec document.getElementById('destinationStation').value='Leeds'; exec $('#destinationStation').keydown(); exec document.querySelectorAll('#destinationStation + div + ul > li > a')[0].click(); exec document.getElementById('isOneWay').checked='checked'; logData 1 execAndWait document.getElementById('submitButton').click(); Script fails due to timing issues
  14. execAndWait to the rescue! navigate http://www.thetrainline.com logData 0 exec document.getElementById('originStation').value='Cheltenham';

    execAndWait $('#originStation').keydown(); exec document.querySelectorAll('#originStation + div + ul > li > a')[0].click(); exec document.getElementById('destinationStation').value='Leeds'; execAndWait $('#destinationStation').keydown(); exec document.querySelectorAll('#destinationStation + div + ul > li > a')[0].click(); exec document.getElementById('isOneWay').checked='checked'; logData 1 execAndWait document.getElementById('submitButton').click();
  15. Authentication Basic Auth setHeader Authorization: Basic dGVzdDp0ZXN0 navigate http://browserspy.dk/password-ok.php Set

    a Cookie setCookie http://www.example.com session=286755fad04869ca523320acce0dc6a4 navigate http://www.example.com/ Fill in a form (as per earlier form examples) base64(username + “:” + password)
  16. Lots more detail on scripting in the docs: https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/scripting Debugging:

    - Use DevTools to check any DOM queries - Save response bodies in WPT (advanced tab) and manually inspect - Watch test execute on Private Instance - Adding sleep or switching to execAndWait can help
  17. Dulles_IE9 Dulles_IE10 Dulles_IE11 Dulles:Chrome Dulles:Canary Dulles:Firefox Dulles:Firefox Nightly Dulles:Safari Dulles_Chrome40

    Dulles_MotoG:Motorola G - Chrome Dulles_MotoG:Motorola G - Chrome Beta Dulles_MotoG:Motorola G - Chrome Dev ec2-us-east-1:Chrome ec2-us-east-1:IE 11 ec2-us-east-1:Firefox ec2-us-east-1:Safari ec2-us-west-1:Chrome ec2-us-west-1:IE 11 ec2-us-west-1:Firefox ec2-us-west-1:Safari ec2-us-west-2:Chrome ec2-us-west-2:IE 11 ec2-us-west-2:Firefox ec2-us-west-2:Safari ec2-eu-west-1:Chrome ec2-eu-west-1:IE 11 ec2-eu-west-1:Firefox ec2-eu-west-1:Safari ec2-eu-central-1:Chrome ec2-eu-central-1:IE 11 ec2-eu-central-1:Firefox ec2-eu-central-1:Safari ec2-ap-northeast-1:Chrome ec2-ap-northeast-1:IE 11 ec2-ap-northeast-1:Firefox ec2-ap-northeast-1:Safari ec2-ap-southeast-1:Chrome ec2-ap-southeast-1:IE 11 ec2-ap-southeast-1:Firefox ec2-ap-southeast-1:Safari ec2-ap-southeast-2:Chrome ec2-ap-southeast-2:IE 11 ec2-ap-southeast-2:Firefox ec2-ap-southeast-2:Safari ec2-sa-east-1:Chrome ec2-sa-east-1:IE 11 ec2-sa-east-1:Firefox ec2-sa-east-1:Safari Works with these public locations
  18. Get a response… { "statusCode": 200, "statusText": "Ok", "data": {

    "testId": "160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76", "ownerKey": "b6a596f5ce4165ef9725bb91d9e4cec75e1f1d8c", "jsonUrl": "http://www.webpagetest.org/jsonResult.php?test=160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76", "xmlUrl": "http://www.webpagetest.org/xmlResult/160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76/", "userUrl": "http://www.webpagetest.org/result/160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76/", "summaryCSV": "http://www.webpagetest.org/result/160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76/page_data.csv", "detailCSV": "http://www.webpagetest.org/result/160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76/requests.csv" } }
  19. { "data": { "statusCode":100, "statusText":"Test Started 13 seconds ago", "id":"160205_N4_d2ea71c14d70c68bb0e3d30a88e59d76",

    "testInfo": { "url":"http:\/\/news.bbc.co.uk", "runs":1, "fvonly":1, . . . }, "statusCode":100, "statusText":"Test Started 15 seconds ago" } Poll the JSON or XML URL
  20. Lots more detail on the API in the docs: https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/scripting

    Marcel Duran’s NodeJS API wrapper: https://github.com/marcelduran/webpagetest-api
  21. Relay mode Passes test to another WPT server and polls

    for results Piggyback on others infrastructure e.g. public agents, Useful for keeping results from ephemeral instances e.g. AWS Or to keep final results within firewall etc.
  22. WebPageTest is really great tool You can use it for

    quick and simple testing but… If you take the time to experiment and learn, you can do a whole lot more.