performance-now.js 886 B

1234567891011121314151617181920212223242526272829303132
  1. // Generated by CoffeeScript 1.7.1
  2. (function() {
  3. var getNanoSeconds, hrtime, loadTime;
  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() - loadTime) / 1e6;
  11. };
  12. hrtime = process.hrtime;
  13. getNanoSeconds = function() {
  14. var hr;
  15. hr = hrtime();
  16. return hr[0] * 1e9 + hr[1];
  17. };
  18. loadTime = getNanoSeconds();
  19. } else if (Date.now) {
  20. module.exports = function() {
  21. return Date.now() - loadTime;
  22. };
  23. loadTime = Date.now();
  24. } else {
  25. module.exports = function() {
  26. return new Date().getTime() - loadTime;
  27. };
  28. loadTime = new Date().getTime();
  29. }
  30. }).call(this);