Skip to content

Commit 39303e2

Browse files
authored
[clang][deps] Improve timing output (#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.
1 parent 03dcefe commit 39303e2

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
@@ -1080,10 +1080,15 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) {
10801080
<< NumExistsCalls << " exists() calls\n"
10811081
<< NumIsLocalCalls << " isLocal() calls\n";
10821082

1083-
if (PrintTiming)
1084-
llvm::errs() << llvm::format(
1085-
"clang-scan-deps timing: %0.2fs wall, %0.2fs process\n",
1086-
T.getTotalTime().getWallTime(), T.getTotalTime().getProcessTime());
1083+
if (PrintTiming) {
1084+
llvm::errs() << "wall time [s]\t"
1085+
<< "process time [s]\t"
1086+
<< "instruction count\n";
1087+
const llvm::TimeRecord &R = T.getTotalTime();
1088+
llvm::errs() << llvm::format("%0.4f", R.getWallTime()) << "\t"
1089+
<< llvm::format("%0.4f", R.getProcessTime()) << "\t"
1090+
<< llvm::format("%llu", R.getInstructionsExecuted()) << "\n";
1091+
}
10871092

10881093
if (RoundTripArgs)
10891094
if (FD && FD->roundTripCommands(llvm::errs()))

0 commit comments

Comments
 (0)