-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Log debug elapsed time using 2 decimal places #5200
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
Log debug elapsed time using 2 decimal places #5200
Conversation
For flags like -debug-time-function-bodies, this makes it easier to measure the impact of parsing functions that take a short amount of time to parse (less than 0.1ms) but are parsed many times and therefore add up over the course of the full build.
This also fixes SR-16 |
Just to get this rolling @swift-ci please smoke test. |
I deliberately picked short precision because this was really only for tracking long times, but the other reason to keep it short is to not imply precision that isn't there. On a regularly loaded system, times can vary quite a bit. How about two decimal places, or even just keeping one, but rounding up first? |
I see. That makes sense. I'm only interested in ensuring that 0.0ms isn't logged, since it isn't that useful. Even though the precision might be there, the situation in which this data is useful is when you have lots of samples because of the nature of the bug. How about 2 decimal places + rounding? This'll give a bit more precision than exists now, while ensuring no 0 values. |
Sounds good to me. Thanks, Ben! |
@@ -155,7 +155,8 @@ namespace { | |||
ASTContext &ctx = Function.getAsDeclContext()->getASTContext(); | |||
|
|||
if (ShouldDump) { | |||
llvm::errs() << llvm::format("%0.1f", elapsed * 1000) << "ms\t"; | |||
// Round to the nearest 100th of a millisecond |
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.
Nitpick: comments should end with periods.
@@ -155,7 +155,8 @@ namespace { | |||
ASTContext &ctx = Function.getAsDeclContext()->getASTContext(); | |||
|
|||
if (ShouldDump) { | |||
llvm::errs() << llvm::format("%0.1f", elapsed * 1000) << "ms\t"; | |||
// Round to the nearest 100th of a millisecond | |||
llvm::errs() << llvm::format("%0.2f", round(elapsed * 100000) / 100) << "ms\t"; |
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.
I thought we settled on ceil
?
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.
Oh I think I read over the "up" part in "rounding up." Will fix!
@swift-ci Please smoke test |
@swift-ci please smoke test. |
[pull] swiftwasm from main
-debug-time-function-bodies
is a useful flag for determining compile-time slowness, but it only logs elapsed parse times to 1/10th of a millisecond. While this is useful if a function takes a long time to parse, it doesn't help determine time lost to parsing function bodies that take a short time to parse (less than 0.1ms) but are parsed multiple times over the course of a build and therefore add up to occupying a significant portion of the build time.Changing this helped me determine the impact of SR-2901.
Resolves SR-16