[PATCH] D38416: [RFC] Add a LIT-style Progress Bar to libSupport

Jonathan Roelofs via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 10:26:05 PDT 2017


jroelofs created this revision.
Herald added a subscriber: mgorny.

I've built this for an out-of-tree use case where we have a tool runs for a very long time. The task itself happens to be reasonably predictable in the amount of work completed, much like the corpus of LIT tests. Since we've already got such a thing in-tree (in python), namely the LIT one, I figured I'd model it off of that.

Usage is something like:

  llvm::ProgressBar PB(llvm::outs(), "Performing Tasks");
  for (int I = 0, E = 100; I != E; ++I) {
    PB.update(I / float(E), (I < 30 ? "Task A" : "Task B"));
    sleep(1);
  }
  PB.clear();

And with that, you get a nice familiar progress bar that looks like:

               Performing Tasks
   20% [=====--------------------] ETA 00:01:20
  Task A

with different colors, to distinguish it from LIT's (sigh... bikeshed away).

Is this something that would be useful upstream? I've thought about tying this into the pass manager, but I don't yet see a consistent way to estimate the total amount of work there. Even then, are there cases where Clang runs for long enough for this to matter?... I don't want this to be an admission of defeat when it comes to compile times. Are there other use cases?

Suggestions on how to write a UnitTest for it are most welcome. As-is, that's a little tricky because this depends on the width of the terminal, so printing it to a `raw_string_ostream` isn't going to give consistent results. I've tested this on Darwin, but I have no idea whether it'll DTRT on other platforms. If it's not platform-agnostic enough, suggestions on how to fix that would also be quite welcome.


https://reviews.llvm.org/D38416

Files:
  include/llvm/Support/Progress.h
  lib/Support/CMakeLists.txt
  lib/Support/Progress.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38416.117167.patch
Type: text/x-patch
Size: 5915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170929/9f14fb98/attachment.bin>


More information about the llvm-commits mailing list