Skip to content

Instantly share code, notes, and snippets.

@vcarl
vcarl / userTimingMiddleware.js
Last active February 8, 2024 05:05 — forked from clarkbw/redux-performance-mark.js
A User Timing middleware for redux to create performance markers for dispatched actions
const userTiming = () => (next) => (action) => {
if (performance.mark === undefined) return next(action);
performance.mark(`${action.type}_start`);
const result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`,
);