Skip to content

Commit 0b69eef

Browse files
committed
Add a walltime message on verbose.
1 parent 1bd62d8 commit 0b69eef

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

bant/bant.cc

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -285,23 +285,30 @@ int main(int argc, char *argv[]) {
285285
flags.grep_regex.append(")");
286286
}
287287

288-
bant::Session session(primary_out, info_out, flags);
289-
290-
// Prepare filesystem
291-
bant::FilesystemPrewarmCacheInit(session, argc, argv);
292-
bant::Filesystem &fs = bant::Filesystem::instance();
293-
PossiblyApplyBazelIgnore(fs);
288+
// TODO: the various scoped areas below look like they actually want
289+
// to be functions.
294290

295-
std::vector<std::string_view> positional_args;
296-
for (int i = optind; i < argc; ++i) {
297-
positional_args.emplace_back(argv[i]);
298-
}
291+
bant::Session session(primary_out, info_out, flags);
292+
absl::Duration runtime;
293+
bant::CliStatus result;
294+
295+
{
296+
bant::ScopedTimer timer(&runtime);
297+
// Prepare filesystem
298+
bant::FilesystemPrewarmCacheInit(session, argc, argv);
299+
bant::Filesystem &fs = bant::Filesystem::instance();
300+
PossiblyApplyBazelIgnore(fs);
301+
302+
std::vector<std::string_view> positional_args;
303+
for (int i = optind; i < argc; ++i) {
304+
positional_args.emplace_back(argv[i]);
305+
}
299306

300-
using bant::CliStatus;
301-
const CliStatus result = RunCliCommand(session, positional_args);
302-
if (result == CliStatus::kExitCommandlineClarification) {
303-
session.error() << "\n\n"; // A bit more space to let message stand out.
304-
return usage(argv[0], nullptr, static_cast<int>(result));
307+
result = RunCliCommand(session, positional_args);
308+
if (result == bant::CliStatus::kExitCommandlineClarification) {
309+
session.error() << "\n\n"; // A bit more space to let message stand out.
310+
return usage(argv[0], nullptr, static_cast<int>(result));
311+
}
305312
}
306313

307314
if (flags.verbose) {
@@ -310,6 +317,7 @@ int main(int argc, char *argv[]) {
310317
for (const std::string_view subsystem : session.stat_keys()) {
311318
std::cerr << subsystem << " " << *session.stat(subsystem) << "\n";
312319
}
320+
std::cerr << "Total walltime " << runtime << "\n";
313321
}
314322
return static_cast<int>(result);
315323
}

0 commit comments

Comments
 (0)