Skip to content

Instantly share code, notes, and snippets.

View protodave's full-sized avatar

protodave protodave

View GitHub Profile
@othiym23
othiym23 / drift.js
Created August 7, 2013 23:23
When I run this using 0.10.15 on "Darwin bauchelain.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64", instead of getting a roughly stable value, I get one that steadily (but not consistently) increases. Are my units wrong? Is V8's timer that out to lunch?
function hrToMillis(hr) {
return (hr[0] * 1e3) + (hr[1] / 1e6);
}
function wtf() {
return Date.now() - hrToMillis(process.hrtime());
}
var basis = wtf();