feat(benchpress): add custom user metric to benchpress
This is a continuation of #7440 (@jeffbcross). Closes #9229
This commit is contained in:
committed by
Tobias Bosch
parent
1eaa193c51
commit
6686bc62f6
@@ -160,6 +160,43 @@ runner.sample({
|
||||
When looking into the DevTools Timeline, we see a marker as well:
|
||||

|
||||
|
||||
### Custom Metrics Without Using `console.time`
|
||||
|
||||
It's also possible to measure any "user metric" within the browser
|
||||
by setting a numeric value on the `window` object. For example:
|
||||
|
||||
```js
|
||||
bootstrap(App)
|
||||
.then(() => {
|
||||
window.timeToBootstrap = Date.now() - performance.timing.navigationStart;
|
||||
});
|
||||
```
|
||||
|
||||
A test driver for this user metric could be written as follows:
|
||||
|
||||
```js
|
||||
|
||||
describe('home page load', function() {
|
||||
it('should log load time for a 2G connection', done => {
|
||||
runner.sample({
|
||||
execute: () => {
|
||||
browser.get(`http://localhost:8080`);
|
||||
},
|
||||
userMetrics: {
|
||||
timeToBootstrap: 'The time in milliseconds to bootstrap'
|
||||
},
|
||||
bindings: [
|
||||
bind(RegressionSlopeValidator.METRIC).toValue('timeToBootstrap')
|
||||
]
|
||||
}).then(done);
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
Using this strategy, benchpress will wait until the specified property name,
|
||||
`timeToBootstrap` in this case, is defined as a number on the `window` object
|
||||
inside the application under test.
|
||||
|
||||
# Smoothness Metrics
|
||||
|
||||
Benchpress can also measure the "smoothness" of scrolling and animations. In order to do that, the following set of metrics can be collected by benchpress:
|
||||
|
||||
Reference in New Issue
Block a user