src: use uv_gettimeofday() by cjihrig · Pull Request #27029 · nodejs/node (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation11 Commits2 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Labeled as a WIP until the next libuv update (ignore the first commit here).
The next version of libuv will provide uv_gettimeofday()
as a cross platform alternative to gettimeofday()
.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes- tests and/or benchmarks are included
- commit message follows commit guidelines
uv_timeval_t ts; |
---|
if (uv_gettimeofday(&ts) == 0) { |
writer.json_keyvalue("dumpEventTimeStamp", |
std::to_string(ts.tv_sec * 1000 + ts.tv_usec / 1000)); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might overflow when tv_sec
is a 32 bits long.
(I kind of regret that we didn't use int64_t
for uv_timeval_t.tv_sec
...)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there's still time to change uv_gettimeofday
to uint64_t uv_gettimeofday()
(or unsigned long long int
) and always return microseconds? Seems like uv_timeval_t
is a little "legacy" for this API
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not a bad idea. Since uv_gettimeofday()
hasn't been released yet, there is time.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bnoordhuis I think I've addressed your nits with the new libuv release.
cjihrig marked this pull request as ready for review
dumpEventTimeStamp was not implemented on Windows, and did not include any error checking. This commit adds Windows support and error checking.
PR-URL: nodejs#27029 Reviewed-By: Refael Ackermann refack@gmail.com
Use uv_gettimeofday() in GetCurrentTimeInMicroseconds() to remove the need for #ifdef logic.
PR-URL: nodejs#27029 Reviewed-By: Refael Ackermann refack@gmail.com
This was referenced
Apr 23, 2019
Labels
Issues and PRs related to general changes in the lib or src directory.