-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Include hooks in time measurement of blocks #638
Conversation
Could you paste an example output here? Thanks! |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 🎉
I just spent too much time on figuring out the performance differences between hrtime.bigint()
, Date.now()
, and new Date().getTime
just to figure out that there is not really a difference for our use case. The only reason why we'd want to switch to hrtime.bigint()
would be a more accurate time measurements (nanoseconds instead of milliseconds), but milliseconds is enough since Jayvee is not fast enough anyway.
If you are interested, here is the test code:
import { hrtime } from 'node:process';
const num_loops = 1;
let start = hrtime.bigint();
for (let i = 0; i < num_loops; i++) {
// do nothing
const x = hrtime.bigint() / 1000_000n;
const y = hrtime.bigint() / 1000_000n;
}
let end = hrtime.bigint();
console.log(`hrtime.bigint() took ${(end - start) / 1000_000n}ms (${(end - start) / 1_000n}µs)`);
start = hrtime.bigint();
for (let i = 0; i < num_loops; i++) {
const x = Date.now();
const y = Date.now();
}
end = hrtime.bigint();
console.log(`Date.now() took ${(end - start) / 1000_000n}ms (${(end - start) / 1_000n}µs)`);
start = hrtime.bigint();
for (let i = 0; i < num_loops; i++) {
const x = new Date().getTime();
const y = new Date().getTime();
}
end = hrtime.bigint();
console.log(`new Date().getTime() took ${(end - start) / 1000_000n}ms (${(end - start) / 1_000n}µs)`);
Thank you for listening to my TED talk, we can merge this how it is.
Closes #637.
This PR adds the hook duration to the debug logger. This is the same level as block duration logging.