blob: d0bfa05977c9550eb87621bd92bbaa7cca8c60a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
/**
* Redux middleware that sets performance markers for all actions such that they
* will appear in performance tooling under the User Timing API
*/
const mark = window.performance?.mark
? window.performance.mark.bind(window.performance)
: a => {};
const measure = window.performance?.measure
? window.performance.measure.bind(window.performance)
: (a, b, c) => {};
export function timing(store) {
return next => action => {
mark(`${action.type}_start`);
const result = next(action);
mark(`${action.type}_end`);
measure(`${action.type}`, `${action.type}_start`, `${action.type}_end`);
return result;
};
}
|