browsertime 17.11.2 → 17.12.1

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,11 +1,21 @@
1
1
  # Browsertime changelog (we do [semantic versioning](https://semver.org))
2
2
 
3
- ## 17.11.1 - 2022-06-19
3
+ ## 17.12.1 - 2022-07-19
4
+ ### Fixed
5
+ * Hmm, Chromedriver 115 doesn't seems to work on Mac so reverted to 114.
6
+
7
+ ## 17.12.0 - 2022-07-19
8
+ ### Added
9
+ * Chrome and Chromedriver 115. The Chrome team has changed the hosting of Chromedriver, so the logic for downloading Chromedriver has changed [#1967](https://github.com/sitespeedio/browsertime/pull/1967).
10
+
11
+ * If you collect the Chrome devtools trace using `--cpu` we will now also collect the number of elements that needs recalculate styles before FCP/LCP.[#1964](https://github.com/sitespeedio/browsertime/pull/1964).
12
+
13
+ ## 17.11.2 - 2022-06-19
4
14
  ### Fixed
5
15
  * Fix --debug mode. Thank you [Gregory Mierzwinski](https://github.com/gmierz) for PR [#1959](https://github.com/sitespeedio/browsertime/pull/1959).
6
16
  * Update ff-test-bidi-har-export to 0.0.11 that fixes some error logs [#1961](https://github.com/sitespeedio/browsertime/pull/1961).
7
17
 
8
- ## 17.11.0 - 2022-06-12
18
+ ## 17.11.1 - 2022-06-12
9
19
  ### Fixed
10
20
  * If Chrome do not collect largest contentful paint, log that instead of just log null [#1957](https://github.com/sitespeedio/browsertime/pull/1957).
11
21
 
@@ -15,6 +15,11 @@ import { parse } from '../traceCategoriesParser.js';
15
15
  import { pathToFolder } from '../../support/pathToFolder.js';
16
16
  import { ChromeDevtoolsProtocol } from '../chromeDevtoolsProtocol.js';
17
17
  import { Android, isAndroidConfigured } from '../../android/index.js';
18
+ import {
19
+ getFirstContentFulPaintEvent,
20
+ getLargestContentfulPaintEvent,
21
+ getRecalculateStyleElementsAndTimeBefore
22
+ } from './traceUtilities.js';
18
23
  const unlink = promisify(_unlink);
19
24
  const rm = promisify(_rm);
20
25
 
@@ -353,6 +358,27 @@ export class Chromium {
353
358
  asset.args.data.renderBlocking;
354
359
  }
355
360
 
361
+ const fcpEvent = getFirstContentFulPaintEvent(trace.traceEvents);
362
+ const lcpEvent = getLargestContentfulPaintEvent(trace.traceEvents);
363
+
364
+ result.renderBlocking = { recalculateStyle: {}, requests: {} };
365
+
366
+ if (fcpEvent) {
367
+ const beforeFCP = getRecalculateStyleElementsAndTimeBefore(
368
+ trace.traceEvents,
369
+ fcpEvent.ts
370
+ );
371
+ result.renderBlocking.recalculateStyle.beforeFCP = beforeFCP;
372
+ }
373
+
374
+ if (lcpEvent) {
375
+ const beforeLCP = getRecalculateStyleElementsAndTimeBefore(
376
+ trace.traceEvents,
377
+ lcpEvent.ts
378
+ );
379
+ result.renderBlocking.recalculateStyle.beforeLCP = beforeLCP;
380
+ }
381
+
356
382
  if (!this.options.skipHar) {
357
383
  for (let harRequest of this.hars[index - 1].log.entries) {
358
384
  if (renderBlockingInfo[harRequest.request.url]) {
@@ -362,7 +388,7 @@ export class Chromium {
362
388
  }
363
389
  }
364
390
 
365
- result.renderBlocking = renderBlockingInfo;
391
+ result.renderBlocking.requests = renderBlockingInfo;
366
392
  }
367
393
 
368
394
  // Google Web Vitals hacksery
@@ -0,0 +1,64 @@
1
+ import intel from 'intel';
2
+ const log = intel.getLogger('browsertime.chrome');
3
+
4
+ export function getLargestContentfulPaintEvent(traceEvents) {
5
+ const lcpCandidates = traceEvents.filter(
6
+ task => task.name === 'largestContentfulPaint::Candidate'
7
+ );
8
+
9
+ if (lcpCandidates.length > 0) {
10
+ let lcpEvent = lcpCandidates[0];
11
+
12
+ for (const candidate of lcpCandidates) {
13
+ if (candidate.ts > lcpEvent.ts) {
14
+ lcpEvent = candidate;
15
+ }
16
+ }
17
+ return lcpEvent;
18
+ } else {
19
+ log.info('No LCP event found in the trace');
20
+ }
21
+ }
22
+
23
+ export function getFirstContentFulPaintEvent(traceEvents) {
24
+ // Get first contentful paint
25
+ const fcpEvent = traceEvents.find(
26
+ task => task.name === 'firstContentfulPaint'
27
+ );
28
+
29
+ if (fcpEvent) {
30
+ return fcpEvent;
31
+ } else {
32
+ log.info('Did not find the FCP event in the trace');
33
+ }
34
+ }
35
+
36
+ export function getRecalculateStyleElementsAndTimeBefore(
37
+ traceEvents,
38
+ timestamp
39
+ ) {
40
+ const recalculatesBefore = traceEvents.filter(
41
+ task =>
42
+ task.cat === 'disabled-by-default-devtools.timeline' &&
43
+ task.name === 'ScheduleStyleRecalculation' &&
44
+ task.ts < timestamp
45
+ );
46
+
47
+ const updateLayoutTree = traceEvents.filter(
48
+ task =>
49
+ task.cat === 'blink,devtools.timeline' &&
50
+ task.name === 'UpdateLayoutTree' &&
51
+ task.ts < timestamp &&
52
+ recalculatesBefore.some(
53
+ recalculate => task.args.beginData.frame === recalculate.args.data.frame
54
+ )
55
+ );
56
+ let elements = 0;
57
+ let duration = 0;
58
+ for (let a of updateLayoutTree) {
59
+ elements += a.args.elementCount;
60
+ duration += a.dur;
61
+ }
62
+
63
+ return { elements, durationInMillis: duration / 1000 };
64
+ }
@@ -404,6 +404,12 @@ export class Collector {
404
404
  results.renderBlocking = [];
405
405
  }
406
406
  results.renderBlocking.push(data.renderBlocking);
407
+
408
+ statistics.addDeep({
409
+ renderBlocking: {
410
+ recalculateStyle: data.renderBlocking.recalculateStyle
411
+ }
412
+ });
407
413
  }
408
414
 
409
415
  // Add power data (if we have it)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "browsertime",
3
3
  "description": "Get performance metrics from your web page using Browsertime.",
4
- "version": "17.11.2",
4
+ "version": "17.12.1",
5
5
  "bin": "./bin/browsertime.js",
6
6
  "type": "module",
7
7
  "dependencies": {