"use strict";

function hrtimeToNanoseconds(time) {
	// If the numbers here become big enough to cause loss of precision, we probably have bigger issues than numeric precision...
	return (time[0] * 1e9) + time[1];
}

module.exports = function measureTime(func) {
	// let startTime = process.hrtime.bigint();
	let startTime = hrtimeToNanoseconds(process.hrtime());
	let result = func();
	// let endTime = process.hrtime.bigint();
	let endTime = hrtimeToNanoseconds(process.hrtime());

	return {
		value: result,
		time: (endTime - startTime)
	};
};
