browsertime 19.1.0 → 19.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
+ ## 19.3.0 - 2023-12-18
4
+
5
+ ### Added
6
+ * Updated Chromedriver and Edgedriver to 120 [#2033](https://github.com/sitespeedio/browsertime/pull/2033).
7
+
8
+ ### Tech
9
+ * Moved the visual metrics python scripts to a new home [#2032](https://github.com/sitespeedio/browsertime/pull/2032).
10
+
11
+ ## 19.2.0 - 2023-12-11
12
+ ### Added
13
+ * Updated to Chrome and Edge 120 in the Docker container [#2031](https://github.com/sitespeedio/browsertime/pull/2031).
14
+
15
+ ### Fixed
16
+ * Updated to Selenium 4.16.0 [#2026](https://github.com/sitespeedio/browsertime/pull/2026).
17
+ * Updated dev dependencies and find-up [#2029](https://github.com/sitespeedio/browsertime/pull/2029).
18
+ * Recommend NodeJS 18 or later in the package.json [#2030](https://github.com/sitespeedio/browsertime/pull/2030). Browsertime 16.0.0 removed support for NodeJS 16.
19
+
3
20
  ## 19.1.0 - 2023-11-27
4
21
 
5
22
  ### Added
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Browsertime - Your browser, your page, your scripts!
1
+ # Browsertime
2
2
  ![Run Docker](https://github.com/sitespeedio/browsertime/actions/workflows/docker.yml/badge.svg?branch=main)
3
3
  ![Unit tests](https://github.com/sitespeedio/browsertime/actions/workflows/unittests.yml/badge.svg?branch=main)
4
4
  ![Windows Edge](https://github.com/sitespeedio/browsertime/actions/workflows/windows.yml/badge.svg?branch=main)
@@ -12,125 +12,113 @@
12
12
 
13
13
  ![Browsertime](browsertime.png)
14
14
 
15
- Access the Web Performance Timeline, from your browser, in your terminal!
15
+ # Browsertime: Measure and Optimize Web Performance
16
16
 
17
- ## Introduction
17
+ Browsertime is a powerful, open-source Node.js tool designed for engineers who are building their own performance measurement tools. It serves as the core engine of projects like sitespeed.io and is a trusted tool used by Mozilla to measure the performance of Firefox.
18
18
 
19
- **Browsertime lets you *automate running JavaScript in your browser* primary used to collect performance metrics. What exactly does that mean?**
19
+ # Table of Contents
20
+ 1. [Introduction](#browsertime-measure-and-optimize-web-performance)
21
+ 2. [Key Features](#key-features)
22
+ 3. [Installation](#installation)
23
+ - [NodeJS](#nodejs)
24
+ - [Docker](#docker)
25
+ 4. [Usage](#usage)
26
+ - [Basic Usage](#basic-usage)
27
+ - [Advanced Options](#advanced-options)
28
+ - [Connectivity](#connectivity)
29
+ - [Navigate in a script](#navigate-in-a-script)
30
+ - [Test on your mobile device](#test-on-your-mobile-device)
31
+ - [Using WebPageReplay](#using-webpagereplay)
32
+ - [Speed Index and video](#speed-index-and-video)
33
+ 5. [Browser Support](#browser-support)
34
+ 6. [How does it work](#how-does-it-work)
35
+ 7. [Contributing](#contributing)
36
+ 9. [Community and Support](#community-and-support)
37
+ 9. [License](#license)
20
38
 
21
- We think of a Browsertime as having four key capabilities:
39
+ ## Key Features
22
40
 
23
- - It handles everything with the browser (Firefox/Chrome/Edge/Safari and other browser that can be driven using WebDriver).
24
- - It executes a batch of default and configurable JavaScript when the URL has finished loading in the browser.
25
- - It records a video of the Browser screen used to calculate [Visual Metrics](https://github.com/WPO-Foundation/visualmetrics).
26
- - It lets you run your [scripting file to create and measure your users journey](https://www.sitespeed.io/documentation/sitespeed.io/scripting/).
41
+ - **Robust Performance Testing:** Browsertime allows you to perform comprehensive performance tests on your web pages, including page load times, resource loading, and user interactions.
27
42
 
28
- **What is Browsertime good for?**
43
+ - **Deep Metrics:** Gain access to a wide range of performance metrics, such as page load times, visual metrics (when things are painted on the screen), largest contentful paint (LCP), and more, helping you pinpoint areas for improvement.
29
44
 
30
- It is usually used for two different things:
45
+ - **Scripting Capabilities:** Customize your tests and user interactions with JavaScript scripting, enabling advanced scenarios and detailed analysis.
31
46
 
32
- - You run it as a standalone tool to collect performance timing metrics of your web site.
33
- - You integrate it in your tool as a JavaScript runner that collects whatever JavaScript metrics/information you want.
47
+ - **Docker Support:** Easily integrate Browsertime into your CI/CD pipelines and containerized environments with Docker support.
48
+ ##
34
49
 
35
- 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:
50
+ ## Installation
36
51
 
37
- 1. You give your configuration to Browsertime.
38
- 2. Browsertime uses the [WebDriver](https://www.w3.org/TR/webdriver/) (through [Selenium](http://seleniumhq.github.io/selenium/docs/api/javascript/index.html)) to start Firefox/Chrome/Safari/Edge.
39
- 3. Browsertime starts FFMPEG to record a video of the browser screen
40
- 4. The browser access the URL.
41
- 5. When the page is finished loading (you can define yourself when that happens), Browsertime collects:
42
- - [Navigation Timing metrics](http://kaaes.github.io/timing/info.html)
43
- - [User Timing metrics](http://www.html5rocks.com/en/tutorials/webperformance/usertiming/)
44
- - [Element Timing metrics](https://wicg.github.io/element-timing/)
45
- - [Paint Timings](https://w3c.github.io/paint-timing/)
46
- - [Googles Web Vitals](https://web.dev/vitals/)
47
- - [CPU metrics CPU Long Tasks]((https://developer.mozilla.org/en-US/docs/Web/API/Long_Tasks_API))
48
- 6. You can also collect internal trace logs from the browser using `--firefox.geckoProfiler` for Firefox and `--chrome.timeline` for Chromium browsers.
49
- 7. It also collects a [HAR](http://www.softwareishard.com/blog/har-12-spec/) file that shows all requests/responses on the page.
50
- 8. FFMpeg is stopped and the video is analysed. Browsertime collect Visual Metrics like Speed Index, First Visual Change and Last Visual Change.
52
+ If you're an engineer working on performance measurement tools or simply want to harness the power of Browsertime for your web performance needs, follow the installation and usage instructions below.
51
53
 
52
- 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.
53
-
54
- ## A simple example
54
+ ### NodeJS
55
+ ```shell
56
+ npm install -g browsertime
57
+ browsertime https://example.com
58
+ ```
55
59
 
56
- Use our Docker image (with Chrome, Firefox, Edge, XVFB and the dependencies needed to record a video):
57
- <pre>
58
- $ docker run --rm -v "$(pwd)":/browsertime sitespeedio/browsertime https://www.sitespeed.io/
59
- </pre>
60
+ ### Docker
61
+ ```shell
62
+ docker run --rm -v "$(pwd)":/browsertime sitespeedio/browsertime https://www.sitespeed.io/
63
+ ```
60
64
 
61
- Or using node:
62
- <pre>
63
- $ npm install browsertime -g
64
- $ browsertime https://www.sitespeed.io/
65
- </pre>
65
+ ## Usage
66
+ Browsertime is designed to be straightforward to use, regardless of your experience level. Here's a quick guide on how to get started.
66
67
 
67
- 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/
68
+ ### Basic Usage
68
69
 
69
- ## I want more examples
70
- Checkout the [examples](docs/examples/README.md).
70
+ ```shell
71
+ browsertime https://www.example.com --browser chrome
72
+ ```
71
73
 
72
- ## Browsers
73
- Browsertime 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.
74
+ This command will test https://www.example.com using Chrome.
74
75
 
75
- ## How does it work
76
- Browsertime uses Selenium NodeJS to drive the browser. It starts the browser, load a URL, executes configurable Javascripts to collect metrics, collect a HAR file.
76
+ ### Advanced Options
77
77
 
78
- To get the HAR from Firefox we use the [HAR Export Trigger](https://github.com/firebug/har-export-trigger) and Chrome we use [Chrome-HAR](https://github.com/sitespeedio/chrome-har) to parse the timeline log and generate the HAR file.
78
+ Browsertime offers various advanced options for more detailed analysis, such as specifying the number of runs, choosing a browser, or setting custom metrics. Here are some examples:
79
79
 
80
- # Speed Index and video
81
- It's easiest to run [our ready made Docker container](https://hub.docker.com/r/sitespeedio/browsertime/) to be able to record a video and calculate SpeedIndex because then you get all dependencies needed for free to run [VisualMetrics](https://github.com/WPO-Foundation/visualmetrics).
80
+ #### Run the test multiple times
82
81
 
83
- The default video will include a timer and showing when the metrics happens, but you can turn that off using <code>--video.addTimer false</code>.
82
+ ```shell
83
+ browsertime -n 5 https://www.example.com
84
+ ```
84
85
 
85
- <img src="https://raw.githubusercontent.com/sitespeedio/sitespeed.io/main/docs/img/video-example.gif">
86
+ #### Specify a different browser
87
+ ```shell
88
+ browsertime --browser firefox https://www.example.com
89
+ ```
86
90
 
87
- ## Test using Docker
88
- You can build and test changes using Docker locally.
91
+ #### Custom metrics
92
+ ```shell
93
+ browsertime --script "return {'myMetric': window.myApp.customMetric}" https://www.example.com
94
+ ```
89
95
 
90
- <pre>
91
- $ docker build -t sitespeedio/browsertime .
92
- $ docker run --rm -v "$(pwd)":/browsertime sitespeedio/browsertime -n 1 https://www.sitespeed.io/
93
- </pre>
96
+ For a full list of options, run <code>$ browsertime --help</code> and you can see the configuration options.
94
97
 
95
- ## Connectivity
98
+ #### Connectivity
96
99
 
97
100
  You 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](https://www.sitespeed.io/documentation/sitespeed.io/connectivity/).
98
101
 
99
-
100
- ## Navigate in a script
102
+ #### Navigate in a script
101
103
  If 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.
102
104
 
103
105
  We have a full section in the documentation about [scripting](https://www.sitespeed.io/documentation/sitespeed.io/scripting/).
104
106
 
105
- ## Test on your mobile device
107
+ #### Test on your mobile device
106
108
  Browsertime supports Chrome and Firefox on Android: Collecting SpeedIndex, HAR and video!
107
109
 
108
110
  You need to [install adb](https://www.sitespeed.io/documentation/sitespeed.io/mobile-phones/#desktop) and [prepare your phone](https://www.sitespeed.io/documentation/sitespeed.io/mobile-phones/#on-your-phone) before you start.
109
111
 
110
- If you want to set connectivity you need to use something like [gnirehtet](https://github.com/Genymobile/gnirehtet) or [TSProxy](https://github.com/WPO-Foundation/tsproxy). Read more information [here](https://www.sitespeed.io/documentation/sitespeed.io/mobile-phones/#connectivity).
112
+ If you want to set connectivity you need to use something like [gnirehtet](https://github.com/Genymobile/gnirehtet). Read more information [here](https://www.sitespeed.io/documentation/sitespeed.io/mobile-phones/#connectivity).
111
113
 
112
114
  <pre>
113
115
  $ browsertime --chrome.android.package com.android.chrome https://www.sitespeed.io --video --visualMetrics
114
116
  </pre>
115
117
 
116
- 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:
117
- * You need to run in privileged mode *--privileged* if you share the full usb bus
118
- * You need to share the USB ports *-v /dev/bus/usb:/dev/bus/usb* or share a specific port with *--device=/dev/bus/usb/001/017* (use *lsusb* to find the right mapping)
119
- * Add *-e START_ADB_SERVER=true* to start the adb server
120
-
121
- 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](https://github.com/sitespeedio/docker-visualmetrics-deps/blob/main/Dockerfile) yourself.
122
-
123
- <pre>
124
- $ 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
125
- </pre>
126
-
127
- ## Configuration
128
- Run <code>$ bin/browsertime.js --help</code> and you can see the configuration options.
129
-
130
- ## Using WebPageReplay
131
- Our Docker container now included [WebPageReplay](https://github.com/catapult-project/catapult/blob/main/web_page_replay_go/README.md).
118
+ #### Using WebPageReplay
119
+ Our Docker container now includes [WebPageReplay](https://github.com/catapult-project/catapult/blob/main/web_page_replay_go/README.md).
132
120
 
133
- WebPageReplay will let you replay your page locally (getting rid of server latency etc) and makes it easier to find front end regressions.
121
+ WebPageReplay will let you replay your page locally (getting rid of server latency) and makes it easier to find front end regressions.
134
122
 
135
123
  It works like this:
136
124
  1. The start script starts WebPageReplay in record mode
@@ -150,23 +138,59 @@ docker run --cap-add=NET_ADMIN --rm -v "$(pwd)":/browsertime -e REPLAY=true -e L
150
138
 
151
139
  Use Firefox:
152
140
 
153
- ```
154
- docker run --cap-add=NET_ADMIN --rm -v "$(pwd)":/browsertime -e REPLAY=true -e LATENCY=100 sitespeedio/browsertime:12.0.0 -b firefox -n 11 --firefox.acceptInsecureCerts https://en.wikipedia.org/wiki/Barack_Obama
141
+ ```shell
142
+ docker run --cap-add=NET_ADMIN --rm -v "$(pwd)":/browsertime -e REPLAY=true -e LATENCY=100 sitespeedio/browsertime:19.2.0 -b firefox -n 11 --firefox.acceptInsecureCerts https://en.wikipedia.org/wiki/Barack_Obama
155
143
  ```
156
144
 
157
145
  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:
158
146
 
159
- ```
147
+ ```shell
160
148
  docker run --privileged -v /dev/bus/usb:/dev/bus/usb -e START_ADB_SERVER=true --cap-add=NET_ADMIN --rm -v “$(pwd)“:/browsertime -e REPLAY=true -e LATENCY=100 sitespeedio/browsertime https://en.m.wikipedia.org/wiki/Barack_Obama --android --chrome.args ignore-certificate-errors-spki-list=PhrPvGIaAMmd29hj8BCZOq096yj7uMpRNHpn5PDxI6I= -n 11 --chrome.args user-data-dir=/data/tmp/chrome
161
149
  ```
162
150
 
163
- ## Send metrics to Graphite
164
- The easiest way to send metrics is to install [jq](https://stedolan.github.io/jq/) and use it to pick the values you wanna track.
151
+ #### Speed Index and video
152
+ It's easiest to run [our ready made Docker container](https://hub.docker.com/r/sitespeedio/browsertime/) to be able to record a video and calculate SpeedIndex because then you get all dependencies needed for free to run [VisualMetrics](https://github.com/WPO-Foundation/visualmetrics).
165
153
 
166
- Here's an example on how you can pickup the median SpeedIndex from Browsertime and send it to your Graphite instance.
167
- <pre>
168
- 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
169
- </pre>
154
+ The default video will include a timer and showing when the metrics happens, but you can turn that off using <code>--video.addTimer false</code>.
155
+
156
+ <img src="https://raw.githubusercontent.com/sitespeedio/sitespeed.io/main/docs/img/video-example.gif">
157
+
158
+
159
+ ## Browser Support
160
+ Browsertime supports Firefox, Chrome, and Edge (Chromium version) on desktop and Safari on Mac OS. On Android we support Chrome and Firefox. Safari on iOS has limited support: there's no HAR file and no visual metrics. You can also use the Safari simulator on Mac OS.
161
+
162
+ ## How does it work
163
+ Browsertime uses Selenium NodeJS to drive the browser. It starts the browser, load a URL, executes configurable Javascripts to collect metrics, collect a HAR file.
164
+
165
+ To get the HAR from Firefox we use the [HAR Export Trigger](https://github.com/firebug/har-export-trigger) and Chrome we use [Chrome-HAR](https://github.com/sitespeedio/chrome-har) to parse the timeline log and generate the HAR file.
166
+
167
+ ## Contributing
168
+
169
+ We welcome contributions from the community! Whether you're fixing a bug, adding a feature, or improving documentation, your help is valuable. Here’s how you can contribute:
170
+
171
+ 1. **Fork and Clone**: Fork the repository and clone it locally.
172
+ 2. **Create a Branch**: Create a new branch for your feature or bug fix.
173
+ 3. **Develop**: Make your changes. Ensure you adhere to the coding standards and write tests if applicable.
174
+ 4. **Test**: Run tests to ensure everything works as expected.
175
+ 5. **Submit a Pull Request**: Push your changes to your fork and submit a pull request to the main repository.
176
+
177
+ Before contributing, please read our [CONTRIBUTING.md](CONTRIBUTING.md) for more detailed information on how to contribute.
178
+
179
+ ### Reporting Issues
180
+ Found a bug or have a feature request? Please use the [GitHub Issues](https://github.com/sitespeedio/browsertime/issues) to report them. Be sure to check existing issues to avoid duplicates.
181
+
182
+ ## Community and Support
183
+
184
+ Join our community! Whether you need help, want to share your experience, or discuss potential improvements, there are several ways to get involved:
185
+
186
+ - **Slack**: Connect with fellow users and the development team on [Slack](https://join.slack.com/t/sitespeedio/shared_invite/zt-296jzr7qs-d6DId2KpEnMPJSQ8_R~WFw).
187
+ - **GitHub Issues**: For technical questions, feature requests, and bug reports, use our [GitHub issues](https://github.com/sitespeedio/browsertime/issues).
188
+
189
+ We're excited to have you in our community and look forward to your contributions and interactions!
190
+
191
+
192
+ ## License
193
+ [Apache License version 2.0](LICENSE).
170
194
 
171
195
  [travis-image]: https://img.shields.io/travis/sitespeedio/browsertime.svg?style=flat-square
172
196
  [travis-url]: https://travis-ci.org/sitespeedio/browsertime
@@ -47,6 +47,8 @@ export class ChromeTrace {
47
47
 
48
48
  result.renderBlocking = render.renderBlocking;
49
49
 
50
+ // The trace do not know about the HAR file so we cannot backfill
51
+ /*
50
52
  if (!this.options.skipHar) {
51
53
  for (let harRequest of this.hars[this.index - 1].log.entries) {
52
54
  if (render.renderBlockingInfo[harRequest.request.url]) {
@@ -54,7 +56,8 @@ export class ChromeTrace {
54
56
  render.renderBlockingInfo[harRequest.request.url];
55
57
  }
56
58
  }
57
- }
59
+
60
+ }*/
58
61
  }
59
62
  } else {
60
63
  throw new Error('Trace only works in Chrome');
@@ -14,7 +14,7 @@ const SCRIPT_PATH = join(
14
14
  '..',
15
15
  '..',
16
16
  '..',
17
- 'browsertime',
17
+ 'visualmetrics',
18
18
  'visualmetrics.py'
19
19
  );
20
20
 
@@ -24,7 +24,7 @@ const PORTABLE_SCRIPT_PATH = join(
24
24
  '..',
25
25
  '..',
26
26
  '..',
27
- 'browsertime',
27
+ 'visualmetrics',
28
28
  'visualmetrics-portable.py'
29
29
  );
30
30
 
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "browsertime",
3
3
  "description": "Get performance metrics from your web page using Browsertime.",
4
- "version": "19.1.0",
4
+ "version": "19.3.0",
5
5
  "bin": "./bin/browsertime.js",
6
6
  "type": "module",
7
7
  "dependencies": {
8
8
  "@cypress/xvfb": "1.2.4",
9
9
  "@devicefarmer/adbkit": "3.2.5",
10
- "@sitespeed.io/chromedriver": "119.0.6045-105",
11
- "@sitespeed.io/edgedriver": "119.0.2151-42",
10
+ "@sitespeed.io/chromedriver": "120.0.6099-71",
11
+ "@sitespeed.io/edgedriver": "120.0.2210-77",
12
12
  "@sitespeed.io/geckodriver": "0.33.0-c",
13
13
  "@sitespeed.io/throttle": "5.0.0",
14
14
  "@sitespeed.io/tracium": "0.3.3",
@@ -19,7 +19,7 @@
19
19
  "dayjs": "1.11.10",
20
20
  "execa": "8.0.1",
21
21
  "fast-stats": "0.0.6",
22
- "find-up": "6.3.0",
22
+ "find-up": "7.0.0",
23
23
  "get-port": "7.0.0",
24
24
  "hasbin": "1.2.3",
25
25
  "intel": "1.2.0",
@@ -29,24 +29,24 @@
29
29
  "lodash.merge": "4.6.2",
30
30
  "lodash.pick": "4.4.0",
31
31
  "lodash.set": "4.3.2",
32
- "selenium-webdriver": "4.15.0",
32
+ "selenium-webdriver": "4.16.0",
33
33
  "yargs": "17.7.2"
34
34
  },
35
35
  "optionalDependencies": {
36
36
  "jimp": "0.22.10"
37
37
  },
38
38
  "devDependencies": {
39
- "ava": "5.3.1",
40
- "eslint": "8.53.0",
41
- "eslint-config-prettier": "9.0.0",
39
+ "ava": "6.0.1",
40
+ "eslint": "8.55.0",
41
+ "eslint-config-prettier": "9.1.0",
42
42
  "eslint-plugin-prettier": "5.0.1",
43
43
  "eslint-plugin-unicorn": "49.0.0",
44
- "prettier": "3.0.3",
44
+ "prettier": "3.1.1",
45
45
  "serve-handler": "6.1.5",
46
46
  "serve": "14.2.1"
47
47
  },
48
48
  "engines": {
49
- "node": ">=14.19.1"
49
+ "node": ">=18.0.0"
50
50
  },
51
51
  "files": [
52
52
  "CHANGELOG.md",
@@ -1 +0,0 @@
1
- #
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,34 +0,0 @@
1
- import unittest
2
- import os
3
-
4
- from browsertime.visualmetrics import (
5
- calculate_contentful_speed_index,
6
- calculate_perceptual_speed_index,
7
- )
8
-
9
- HERE = os.path.dirname(__file__)
10
-
11
-
12
- class TestVisualMetrics(unittest.TestCase):
13
- def setUp(self):
14
- self.directory = "test_data"
15
- images = os.listdir(os.path.join(HERE, self.directory))
16
-
17
- def _p(image):
18
- p = {}
19
- p["time"] = int(image.split(".")[0].split("ms_")[-1])
20
- return p
21
-
22
- progress = [_p(image) for image in images if image.startswith("ms_")]
23
- self.sorted_progress = sorted(progress,
24
- key = lambda image: image['time'])
25
-
26
- def test_calculate_contentful_speed_index(self):
27
- res = calculate_contentful_speed_index(self.sorted_progress,
28
- self.directory)
29
- self.assertEqual(res[0], 1188)
30
-
31
- def test_calculate_perceptual_speed_index(self):
32
- res = calculate_perceptual_speed_index(self.sorted_progress,
33
- self.directory)
34
- self.assertEqual(res[0], 946)