performance-now.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Generated by CoffeeScript 1.12.2
  2. (function() {
  3. var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;
  4. if ((typeof performance !== "undefined" && performance !== null) && performance.now) {
  5. module.exports = function() {
  6. return performance.now();
  7. };
  8. } else if ((typeof process !== "undefined" && process !== null) && process.hrtime) {
  9. module.exports = function() {
  10. return (getNanoSeconds() - nodeLoadTime) / 1e6;
  11. };
  12. hrtime = process.hrtime;
  13. getNanoSeconds = function() {
  14. var hr;
  15. hr = hrtime();
  16. return hr[0] * 1e9 + hr[1];
  17. };
  18. moduleLoadTime = getNanoSeconds();
  19. upTime = process.uptime() * 1e9;
  20. nodeLoadTime = moduleLoadTime - upTime;
  21. } else if (Date.now) {
  22. module.exports = function() {
  23. return Date.now() - loadTime;
  24. };
  25. loadTime = Date.now();
  26. } else {
  27. module.exports = function() {
  28. return new Date().getTime() - loadTime;
  29. };
  30. loadTime = new Date().getTime();
  31. }
  32. }).call(this);
  33. //# sourceMappingURL=performance-now.js.map