daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This code can be run in the Chrome console
  2. const benchmark = () => {
  3.   const UIAccordionItem = hubspot.getLoadedModules()['UIComponents/accordion/UIAccordionItem'];
  4.  
  5.   const REPS = 1e6;
  6.  
  7.   const instance = {
  8.     props: {
  9.       ...UIAccordionItem.defaultProps,
  10.       children: 'Hello',
  11.     },
  12.     state: {
  13.       openComplete: false,
  14.     }
  15.   }
  16.  
  17.   // Warm up the code path
  18.   for (let i = 0; i < REPS; i++) {
  19.     React.addons.shallowCompare(instance, {
  20.       ...UIAccordionItem.defaultProps,
  21.       children: 'Hello',
  22.     }, instance.state);
  23.   }
  24.  
  25.   const start = performance.now();
  26.   for (let i = 0; i < REPS; i++) {
  27.     React.addons.shallowCompare(instance, {
  28.       ...UIAccordionItem.defaultProps,
  29.       children: 'Hello',
  30.     }, instance.state);
  31.   }
  32.   console.log(`${REPS} repetitions of shallow-compare took ${performance.now() - start}ms`);
  33. }
  34.  
  35. benchmark();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top