stats.js 652 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * @fileoverview Provides helper functions to start/stop the time measurements
  3. * that are provided by the ESLint 'stats' option.
  4. * @author Mara Kiefer <http://github.com/mnkiefer>
  5. */
  6. "use strict";
  7. /**
  8. * Start time measurement
  9. * @returns {[number, number]} t variable for tracking time
  10. */
  11. function startTime() {
  12. return process.hrtime();
  13. }
  14. /**
  15. * End time measurement
  16. * @param {[number, number]} t Variable for tracking time
  17. * @returns {number} The measured time in milliseconds
  18. */
  19. function endTime(t) {
  20. const time = process.hrtime(t);
  21. return time[0] * 1e3 + time[1] / 1e6;
  22. }
  23. module.exports = {
  24. startTime,
  25. endTime
  26. };