From 6e49cf06e2b1eeb659afd8175e5a571f5de95467 Mon Sep 17 00:00:00 2001 From: Ben Asher Date: Sun, 9 Oct 2016 11:28:02 -0700 Subject: [PATCH 1/3] Log debug elapsed time using 3 decimal places 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. --- lib/Sema/TypeCheckStmt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp index d858a8cdb529e..519668b0dae2a 100644 --- a/lib/Sema/TypeCheckStmt.cpp +++ b/lib/Sema/TypeCheckStmt.cpp @@ -155,7 +155,7 @@ namespace { ASTContext &ctx = Function.getAsDeclContext()->getASTContext(); if (ShouldDump) { - llvm::errs() << llvm::format("%0.1f", elapsed * 1000) << "ms\t"; + llvm::errs() << llvm::format("%0.3f", elapsed * 1000) << "ms\t"; Function.getLoc().print(llvm::errs(), ctx.SourceMgr); if (auto *AFD = Function.getAbstractFunctionDecl()) { From 56629383aedf194ec37ee6cbbeb9cd331f3174c7 Mon Sep 17 00:00:00 2001 From: Ben Asher Date: Mon, 10 Oct 2016 15:08:52 -0700 Subject: [PATCH 2/3] Round to nearest 100th of a millisecond --- lib/Sema/TypeCheckStmt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp index 519668b0dae2a..087516828730c 100644 --- a/lib/Sema/TypeCheckStmt.cpp +++ b/lib/Sema/TypeCheckStmt.cpp @@ -155,7 +155,8 @@ namespace { ASTContext &ctx = Function.getAsDeclContext()->getASTContext(); if (ShouldDump) { - llvm::errs() << llvm::format("%0.3f", elapsed * 1000) << "ms\t"; + // Round to the nearest 100th of a millisecond + llvm::errs() << llvm::format("%0.2f", round(elapsed * 100000) / 100) << "ms\t"; Function.getLoc().print(llvm::errs(), ctx.SourceMgr); if (auto *AFD = Function.getAbstractFunctionDecl()) { From d14a49b44a53fe006df3e9642bfb87b00014f269 Mon Sep 17 00:00:00 2001 From: Ben Asher Date: Mon, 10 Oct 2016 16:27:17 -0700 Subject: [PATCH 3/3] Add period. Use ceil instead of round --- lib/Sema/TypeCheckStmt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp index 087516828730c..1d1a9a9548634 100644 --- a/lib/Sema/TypeCheckStmt.cpp +++ b/lib/Sema/TypeCheckStmt.cpp @@ -155,8 +155,8 @@ namespace { ASTContext &ctx = Function.getAsDeclContext()->getASTContext(); if (ShouldDump) { - // Round to the nearest 100th of a millisecond - llvm::errs() << llvm::format("%0.2f", round(elapsed * 100000) / 100) << "ms\t"; + // Round up to the nearest 100th of a millisecond. + llvm::errs() << llvm::format("%0.2f", ceil(elapsed * 100000) / 100) << "ms\t"; Function.getLoc().print(llvm::errs(), ctx.SourceMgr); if (auto *AFD = Function.getAbstractFunctionDecl()) {