I'm trying to figure out how to write a clean function that is supported by both Node and the browser, but feel that the cleanliness of the solution is not as good as it could be.
Would it be hacky to have conditionals checking the presence of the window object?
if (typeof window !== undefined)
// node computation
else
// browser computation
But I also want a clean way to compute the total execution time before and after some operation. How should I go about this?