Skip to content

Instantly share code, notes, and snippets.

@clarkbw
Last active June 12, 2023 10:14
  • Star 47 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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;
};
@vcarl
Copy link

vcarl commented Jun 10, 2018

Wanted to thank you for this! Popped up first when I googled "user timing api redux" and worked flawlessly.

@mbeaudru
Copy link

mbeaudru commented May 7, 2019

I second this, very useful middleware !

@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