Skip to content

Commit 67e11cb

Browse files
committed
[clang][deps] Improve timing output (llvm#113726)
This patch adds the number of executed instructions into the timing output, which provides more stable results compared to wall or process time. The format itself is also tweaked so that it's more amenable for direct import into a spreadsheet editor. (cherry picked from commit 39303e2)
1 parent 240db8d commit 67e11cb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

clang/test/ClangScanDeps/print-timing.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
// RUN: clang-scan-deps -compilation-database %t/cdb.json -print-timing > %t/result.json 2>%t/errs
55
// RUN: cat %t/errs | FileCheck %s
6-
// CHECK: clang-scan-deps timing: {{[0-9]+}}.{{[0-9][0-9]}}s wall, {{[0-9]+}}.{{[0-9][0-9]}}s process
6+
// CHECK: wall time [s] process time [s] instruction count
7+
// CHECK-NEXT: {{[0-9]+}}.{{([0-9]{4})}} {{[0-9]+}}.{{([0-9]{4})}} {{[0-9]+}}
78

89
//--- cdb.json
910
[]

clang/tools/clang-scan-deps/ClangScanDeps.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,10 +1398,15 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) {
13981398
}
13991399

14001400
T.stopTimer();
1401-
if (PrintTiming)
1402-
llvm::errs() << llvm::format(
1403-
"clang-scan-deps timing: %0.2fs wall, %0.2fs process\n",
1404-
T.getTotalTime().getWallTime(), T.getTotalTime().getProcessTime());
1401+
if (PrintTiming) {
1402+
llvm::errs() << "wall time [s]\t"
1403+
<< "process time [s]\t"
1404+
<< "instruction count\n";
1405+
const llvm::TimeRecord &R = T.getTotalTime();
1406+
llvm::errs() << llvm::format("%0.4f", R.getWallTime()) << "\t"
1407+
<< llvm::format("%0.4f", R.getProcessTime()) << "\t"
1408+
<< llvm::format("%llu", R.getInstructionsExecuted()) << "\n";
1409+
}
14051410

14061411
if (RoundTripArgs)
14071412
if (FD && FD->roundTripCommands(llvm::errs()))

0 commit comments

Comments
 (0)