闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
971 B

  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. //
  6. let marky;
  7. if (process.env.NODE_ENV === 'development') {
  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. marky = require('marky');
  14. // allows us to easily do e.g. ReactPerf.printWasted() while debugging
  15. window.ReactPerf = require('react-addons-perf');
  16. window.ReactPerf.start();
  17. }
  18. export function start(name) {
  19. if (process.env.NODE_ENV === 'development') {
  20. marky.mark(name);
  21. }
  22. }
  23. export function stop(name) {
  24. if (process.env.NODE_ENV === 'development') {
  25. marky.stop(name);
  26. }
  27. }