performanceNow.js 719 B

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. /**
  3. * Copyright (c) 2013-present, Facebook, Inc.
  4. *
  5. * This source code is licensed under the MIT license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. *
  8. * @typechecks
  9. */
  10. var performance = require('./performance');
  11. var performanceNow;
  12. /**
  13. * Detect if we can use `window.performance.now()` and gracefully fallback to
  14. * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
  15. * because of Facebook's testing infrastructure.
  16. */
  17. if (performance.now) {
  18. performanceNow = function performanceNow() {
  19. return performance.now();
  20. };
  21. } else {
  22. performanceNow = function performanceNow() {
  23. return Date.now();
  24. };
  25. }
  26. module.exports = performanceNow;