performance.js 951 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // Tools for performance debugging, only enabled in development mode.
  3. // Open up Chrome Dev Tools, then Timeline, then User Timing to see output.
  4. // Also see config/webpack/loaders/mark.js for the webpack loader marks.
  5. import * as marky from 'marky';
  6. import { isDevelopment } from './utils/environment';
  7. if (isDevelopment()) {
  8. if (typeof performance !== 'undefined' && performance.setResourceTimingBufferSize) {
  9. // Increase Firefox's performance entry limit; otherwise it's capped to 150.
  10. // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1331135
  11. performance.setResourceTimingBufferSize(Infinity);
  12. }
  13. // allows us to easily do e.g. ReactPerf.printWasted() while debugging
  14. //window.ReactPerf = require('react-addons-perf');
  15. //window.ReactPerf.start();
  16. }
  17. export function start(name) {
  18. if (isDevelopment()) {
  19. marky.mark(name);
  20. }
  21. }
  22. export function stop(name) {
  23. if (isDevelopment()) {
  24. marky.stop(name);
  25. }
  26. }