How to use the react-addons-perf.start function in react-addons-perf

To help you get started, we’ve selected a few react-addons-perf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liangklfangl / react-universal-bucket / src / containers / App / App.js View on Github external
import { isLoaded as isAuthLoaded, load as loadAuth, logout } from '../../redux/modules/auth';
// export function isLoaded(globalState) {
//   return globalState.auth && globalState.auth.loaded;
// }
// 下面是loadAuth方法
// export function load() {
//   return {
//     types: [LOAD, LOAD_SUCCESS, LOAD_FAIL],
//     promise: (client) => client.get('/loadAuth')
//   };
// }
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import Header from "../../components/Header/index";
import Footer from "../../components/Footer/index";
Perf.start();
// const styles = require("./App.less");
 //(1)延缓容器的渲染直到异步的请求结束(该redux-async-connect返回一个promise,直到这个promise被resolve或者reject后才会渲染我们的react-router对应的组件树)
 //(2)保存数据到store中,同时将加载的数据connect到你的容器中~
 //也就是说,在加载这个页面之前我们要获取到所有的/loadInfo等以及用户是否登录等信息
 //获取到之后才会真正渲染页面~~~
@asyncConnect([{
  promise: ({store: {dispatch, getState},helpers}) => {
    // loadOnServer({...renderProps, store, helpers: {client}})
    // 这部分代码在服务端执行,是服务端在内网发送的ajax请求,因此没有filter属性,loadOnServer中不存在filter
    // 因此这里我们的promise函数中可以获取到helpers对象,其是一个{client:{ApiClient}}
    // console.log("App的@asyncConnect中的filter,helpers",filter);
    // console.log("App的@asyncConnect中的filter,helpers",helpers);
  //里面无法直接访问store,否则报错,里面调用getState得到的值参见
  //getState.js
  const promises = [];
  const state = getState();
github amrav / sparrow / ui / src / socket.js View on Github external
const dispatchMessage = (msg) => {
    // let timer = profiler.start('dispatchMessage');
    Perf.start();
    if (msg.type === RECEIVE_MESSAGE) {
        store.dispatch(newTabMaybe('Hub', 'hubMessages', ''));
    } else if (msg.type === RECEIVE_PRIVATE_MESSAGE) {
        store.dispatch(newTabMaybe(msg.from, 'privateMessages', msg.from));
    }
    store.dispatch(msg);
    Perf.stop();
    const measurements = Perf.getLastMeasurements();
    // Perf.printInclusive(measurements);
    Perf.printExclusive(measurements);
    Perf.printWasted(measurements);
    // timer.stop('dispatchMessage');
};
github adazzle / react-data-grid / src / __tests__ / Grid-perf.spec.js View on Github external
it('should not waste instances on scroll', (done) => {
      const COLUMNS_TO_SCROLL = 20;
      grid.selectCell({cellIdx: 0, rowIdx: 0});
      ReactPerf.start();

      doHorizontalScroll(0, 0, COLUMNS_TO_SCROLL, grid, onScrollComplete.bind(null, done), ScrollType.HORIZONTAL);
    });
  });
github mui-org / material-ui / test / integration / fixtures / perf / TimeWaster.js View on Github external
runTest() {
    let i = 0;
    Perf.start();
    return new Promise(resolve => {
      const execTest = () => {
        i += 1;
        setTimeout(() => {
          if (i < this.props.loops) {
            this.setTestProp(execTest);
          } else {
            Perf.stop();
            resolve(Perf);
          }
        }, 10);
      };
      execTest();
    });
  }
github sheepsteak / react-perf-component / src / index.js View on Github external
componentDidUpdate() {
      ReactPerf.stop();

      const measurements = ReactPerf.getLastMeasurements();

      ReactPerf.printWasted(measurements);
      ReactPerf.start();
    }
github fdietz / whistler_news_reader / client / js / middleware / performance.js View on Github external
export const reactPerformance = () => next => action => {
  Perf.start();
  const result = next(action);
  Perf.stop();

  Perf.printWasted();

  return result;
};