Skip to content

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

Merged
merged 3 commits into from
Oct 11, 2016

Conversation

benasher44
Copy link
Contributor

@benasher44 benasher44 commented Oct 9, 2016

-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

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.
@mxswd
Copy link
Contributor

mxswd commented Oct 9, 2016

This also fixes SR-16

@CodaFi
Copy link
Contributor

CodaFi commented Oct 10, 2016

Just to get this rolling

@swift-ci please smoke test.

@jrose-apple
Copy link
Contributor

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?

@benasher44
Copy link
Contributor Author

benasher44 commented Oct 10, 2016

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.

@jrose-apple
Copy link
Contributor

Sounds good to me. Thanks, Ben!

@benasher44 benasher44 changed the title Log debug elapsed time using 3 decimal places Log debug elapsed time using 2 decimal places Oct 10, 2016
@@ -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
Copy link
Contributor

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";
Copy link
Contributor

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?

Copy link
Contributor Author

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!

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented Oct 11, 2016

@swift-ci please smoke test.

@jrose-apple jrose-apple merged commit e5f7ef9 into swiftlang:master Oct 11, 2016
MaxDesiatov pushed a commit that referenced this pull request Sep 7, 2023
[pull] swiftwasm from main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants