Skip to content

Commit

Permalink
fix: totalBlockingTime and storageEstimate
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Apr 19, 2020
1 parent 82f85a0 commit 9574d0b
Show file tree
Hide file tree
Showing 10 changed files with 2,449 additions and 4,304 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 5.0.0-rc.4 (2020-3-19)

* **fix:** solved issue with `storageEstimate` and created his own event
* **fix:** removed extra calls for `totalBlockingTime`

## 5.0.0-rc.3 (2020-3-18)

* **feat:** added Total Blocking Time [#112](https://github.com/Zizzamia/perfume.js/issues/112)
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="https://github.com/Zizzamia/perfume.js/blob/master/docs/src/assets/perfume-logo-v4-5-0.png" align="left" width="200" />
</a>

# [Perfume.js v5.0.0-rc.2](http://perfumejs.com)
# [Perfume.js v5.0.0-rc.4](http://perfumejs.com)

[![NPM version](https://badge.fury.io/js/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Build Status](https://travis-ci.org/Zizzamia/perfume.js.svg?branch=master)](https://travis-ci.org/Zizzamia/perfume.js) [![NPM Downloads](http://img.shields.io/npm/dm/perfume.js.svg)](https://www.npmjs.org/package/perfume.js) [![Test Coverage](https://api.codeclimate.com/v1/badges/f813d2f45b274d93b8c5/test_coverage)](https://codeclimate.com/github/Zizzamia/perfume.js/test_coverage) [![JS gzip size](https://img.badgesize.io/https://unpkg.com/perfume.js?compression=gzip&label=JS+gzip+size)](https://unpkg.com/perfume.js)

Expand All @@ -19,7 +19,7 @@ Perfume is a tiny, web performance monitoring library which reports field data b
- ⏰ Supports latest Performance APIs for precise metrics
- 🔨 Cross browser tested
- 🚿 Filters out false positive/negative results
- 🤙 Only 2Kb gzip
- 🤙 Only 2.4Kb gzip
- 🛰 Flexible analytics tool
- ⚡️ Waste-zero ms with [requestIdleCallback](https://developers.google.com/web/updates/2015/08/using-requestidlecallback) strategy built-in
<br />
Expand Down Expand Up @@ -192,6 +192,15 @@ First Input Delay is run by default.
// Perfume.js: Cumulative Layout Shift score 0.13
```

### Total Blocking Time (TBT)
**Total Blocking Time** (TBT) is an important, user-centric metric for measuring load responsiveness because it helps quantify the severity of how non-interactive a page is prior to it becoming reliably interactive—a low TBT helps ensure that the page is usable.

```javascript
// Perfume.js: totalBlockingTime 347.07 ms
// Perfume.js: totalBlockingTime5S 427.14 ms
// Perfume.js: totalBlockingTime10S 427.14 ms
```

### Resource Timing
Resource Timing collects performance metrics for document-dependent resources. Stuff like style sheets, scripts, images, et cetera.
Perfume helps expose all PerformanceResourceTiming entries and group data data consumption by Kb used.
Expand Down
1 change: 1 addition & 0 deletions __tests__/_mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default {
value: navigator,
writable: true,
});
return navigator;
},
performance: () => {
delete (window as any).performance;
Expand Down
29 changes: 5 additions & 24 deletions __tests__/perfume.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ describe('Perfume', () => {
isLowEndDevice: false,
isLowEndExperience: false,
serviceWorkerStatus: 'unsupported',
storageEstimateQuota: 9.54,
storageEstimateUsage: 8.58,
},
});
});
Expand Down Expand Up @@ -134,8 +132,6 @@ describe('Perfume', () => {
isLowEndDevice: false,
isLowEndExperience: false,
serviceWorkerStatus: 'unsupported',
storageEstimateQuota: 9.54,
storageEstimateUsage: 8.58,
},
});
});
Expand Down Expand Up @@ -573,8 +569,6 @@ describe('Perfume', () => {
isLowEndDevice: false,
isLowEndExperience: false,
serviceWorkerStatus: 'unsupported',
storageEstimateQuota: 9.54,
storageEstimateUsage: 8.58,
},
});
});
Expand All @@ -592,8 +586,6 @@ describe('Perfume', () => {
isLowEndDevice: false,
isLowEndExperience: false,
serviceWorkerStatus: 'unsupported',
storageEstimateQuota: 9.54,
storageEstimateUsage: 8.58,
},
});
});
Expand Down Expand Up @@ -651,8 +643,6 @@ describe('Perfume', () => {
deviceMemory: 8,
hardwareConcurrency: 12,
serviceWorkerStatus: 'unsupported',
storageEstimateQuota: 9.54,
storageEstimateUsage: 8.58,
});
});
});
Expand Down Expand Up @@ -878,21 +868,12 @@ describe('Perfume', () => {
});
});

describe('.setStorageEstimate()', () => {
it('when navigator is not supported should not set storageEstimate values', () => {
describe('.initStorageEstimate()', () => {
it('when navigator is not supported should not call logData', () => {
spy = jest.spyOn(perfume as any, 'logData');
delete (perfume as any).wn;
(perfume as any).storageEstimateQuota = null;
(perfume as any).storageEstimateUsage = null;
(perfume as any).setStorageEstimate();
expect((perfume as any).storageEstimateQuota).toEqual(null);
expect((perfume as any).storageEstimateUsage).toEqual(null);
});

it('when navigator is supported should set storageEstimate values', () => {
mock.navigator();
(perfume as any).setStorageEstimate();
expect((perfume as any).storageEstimateQuota).toEqual(9.54);
expect((perfume as any).storageEstimateUsage).toEqual(8.58);
(perfume as any).initStorageEstimate();
expect(spy.mock.calls.length).toEqual(0);
});
});
});
Loading

0 comments on commit 9574d0b

Please sign in to comment.