Skip to content
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

[clang][deps] Improve timing output #113726

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions clang/tools/clang-scan-deps/ClangScanDeps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ static bool DeprecatedDriverCommand;
static ResourceDirRecipeKind ResourceDirRecipe;
static bool Verbose;
static bool PrintTiming;
static bool NoPrintTimingHeader;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: even if the command-line argument is "-no" I would phrase this as PrintTimingHeader with default true.

static llvm::BumpPtrAllocator Alloc;
static llvm::StringSaver Saver{Alloc};
static std::vector<const char *> CommandLine;
Expand Down Expand Up @@ -220,6 +221,7 @@ static void ParseArgs(int argc, char **argv) {
}

PrintTiming = Args.hasArg(OPT_print_timing);
NoPrintTimingHeader = Args.hasArg(OPT_no_print_timing_header);

Verbose = Args.hasArg(OPT_verbose);

Expand Down Expand Up @@ -1080,10 +1082,16 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) {
<< NumExistsCalls << " exists() calls\n"
<< NumIsLocalCalls << " isLocal() calls\n";

if (PrintTiming)
llvm::errs() << llvm::format(
"clang-scan-deps timing: %0.2fs wall, %0.2fs process\n",
T.getTotalTime().getWallTime(), T.getTotalTime().getProcessTime());
if (PrintTiming) {
if (!NoPrintTimingHeader)
llvm::errs() << "wall time [s]\t"
<< "process time [s]\t"
<< "instruction count\n";
const llvm::TimeRecord &R = T.getTotalTime();
llvm::errs() << llvm::format("%0.4f", R.getWallTime()) << "\t"
<< llvm::format("%0.4f", R.getProcessTime()) << "\t"
<< llvm::format("%llu", R.getInstructionsExecuted()) << "\n";
}

if (RoundTripArgs)
if (FD && FD->roundTripCommands(llvm::errs()))
Expand Down
1 change: 1 addition & 0 deletions clang/tools/clang-scan-deps/Opts.td
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def deprecated_driver_command : F<"deprecated-driver-command", "use a single dri
defm resource_dir_recipe : Eq<"resource-dir-recipe", "How to produce missing '-resource-dir' argument">;

def print_timing : F<"print-timing", "Print timing information">;
def no_print_timing_header : F<"no-print-timing-header", "Do not print the timing information header">;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something you've found useful in practice? Naively I would look for a shell one-liner like piping to sed 1d


def verbose : F<"v", "Use verbose output">;

Expand Down
Loading