Skip to content

Instantly share code, notes, and snippets.

@clarkbw
Last active February 8, 2024 05:03
Show Gist options
  • Star 48 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save clarkbw/966732806e7a38f5b49fd770c62a6099 to your computer and use it in GitHub Desktop.
Save clarkbw/966732806e7a38f5b49fd770c62a6099 to your computer and use it in GitHub Desktop.
A User Timing middleware for redux to create performance markers for dispatched actions
const timing = store => next => action => {
performance.mark(`${action.type}_start`);
let result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`
);
return result;
};
@yoerivdm
Copy link

yoerivdm commented May 5, 2020

Thanks! Exactly what I need :-)

@clarkbw
Copy link
Author

clarkbw commented May 5, 2020

Wow, thanks! I’d never seen these comments before 🤩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment