在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:sitespeedio/browsertime开源软件地址:https://github.com/sitespeedio/browsertime开源编程语言:JavaScript 70.5%开源软件介绍:Browsertime - Your browser, your page, your scripts!Access the Web Performance Timeline, from your browser, in your terminal! IntroductionBrowsertime lets you automate running JavaScript in your browser primary used to collect performance metrics. What exactly does that mean? We think of a Browsertime as having four key capabilities:
What is Browsertime good for? It is usually used for two different things:
To understand how Browsertime do these things, let's talk about how it works. Here's an example of what happens when you give Browsertime a URL to test:
The result of the run is a JSON file with all the JavaScript metrics collected, a HAR file, a video recording of the screen and a screenshot. A simple exampleUse our Docker image (with Chrome, Firefox, Edge, XVFB and the dependencies needed to record a video): $ docker run --rm -v "$(pwd)":/browsertime sitespeedio/browsertime https://www.sitespeed.io/ Or using node: $ npm install browsertime -g $ browsertime https://www.sitespeed.io/ Load https://www.sitespeed.io/ in Chrome three times. Results are stored in a JSON file (browsertime.json) with the timing data, and a HAR file (browsertime.har) in browsertime-results/www.sitespeed.io/$date/ I want more examplesCheckout the examples. BrowsersBrowsertime supports Firefox, Chrome, and Edge (Chromium version) on desktop and Safari on Mac OS. On Android we support Chrome and Firefox (from 8.0) and Safari on iOS. You can also use the Safari simulator on Mac OS. How does it workBrowsertime uses Selenium NodeJS to drive the browser. It starts the browser, load a URL, executes configurable Javascripts to collect metrics, collect a HAR file. To get the HAR from Firefox we use the HAR Export Trigger and Chrome we use Chrome-HAR to parse the timeline log and generate the HAR file. Speed Index and videoIt's easiest to run our ready made Docker container to be able to record a video and calculate SpeedIndex because then you get all dependencies needed for free to run VisualMetrics. The default video will include a timer and showing when the metrics happens, but you can turn that off using Test using DockerYou can build and test changes using Docker locally. $ docker build -t sitespeedio/browsertime . $ docker run --rm -v "$(pwd)":/browsertime sitespeedio/browsertime -n 1 https://www.sitespeed.io/ ConnectivityYou can throttle the connection to make the connectivity slower to make it easier to catch regressions. The best way to do that is to setup a network bridge in Docker or use our connectivity engine Throttle. Read more about how to do that in the documentation. Navigate in a scriptIf you need a more complicated test scenario, you can define your own (Selenium)test script that will do the testing. Use your own test script when you want to test your page as a logged in user, the login page or if you want to add things to your cart. We have a full section in the documentation about scripting. Test on your mobile deviceBrowsertime supports Chrome and Firefox on Android: Collecting SpeedIndex, HAR and video! You need to install adb and prepare your phone before you start. If you want to set connectivity you need to use something like gnirehtet or TSProxy. Read more information here. $ browsertime --chrome.android.package com.android.chrome https://www.sitespeed.io --video --visualMetrics If you are on Linux (we have tested Ubuntu 18) you can use our Docker container to drive your Android phone. A couple of things to remember:
If you use Docker you will automatically get support for video and SpeedIndex. You can get that without Docker but then need to install VisualMetrics dependencies yourself. $ docker run --privileged -v /dev/bus/usb:/dev/bus/usb -e START_ADB_SERVER=true --rm -v "$(pwd)":/browsertime-results sitespeedio/browsertime -n 1 --android --visualMetrics --video https://en.m.wikipedia.org/wiki/Barack_Obama ConfigurationRun Using WebPageReplayOur Docker container now included WebPageReplay. WebPageReplay will let you replay your page locally (getting rid of server latency etc) and makes it easier to find front end regressions. It works like this:
You can change latency by setting a Docker environment variable. Use REPLAY to turn on the reply functionality. Default browser is Chrome:
Use Firefox:
And Chrome on your Android phone. This will only work on Linux because you need to be able to mount the usb port in Docker:
Send metrics to GraphiteThe easiest way to send metrics is to install jq and use it to pick the values you wanna track. Here's an example on how you can pickup the median SpeedIndex from Browsertime and send it to your Graphite instance. echo "browsertime.your.key.SpeedIndex.median" $(cat /tmp/browsertime/browsertime.json | jq .[0].statistics.visualMetrics.SpeedIndex.median) "`date +%s`" | nc -q0 my.graphite.com 2003 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论