aboutsummaryrefslogtreecommitdiff
path: root/utils/optimin/src/ProgressBar.h
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-07-29 09:37:44 +0200
committerGitHub <noreply@github.com>2021-07-29 09:37:44 +0200
commit50e26ea1a70549be544769d67c17f4a537d6c2e7 (patch)
tree12cb28ba6568c6ca1a6f69cfb43507b5fe36eb0d /utils/optimin/src/ProgressBar.h
parentea39e6d6e7b3329ff744e3a28b32b8862251d4cc (diff)
parent0bd6fda98b4d376d40a87d5efb8cc4fa761a453e (diff)
downloadafl++-50e26ea1a70549be544769d67c17f4a537d6c2e7.tar.gz
Merge pull request #1047 from adrianherrera/fixes/optimin
Fixes/optimin
Diffstat (limited to 'utils/optimin/src/ProgressBar.h')
-rw-r--r--utils/optimin/src/ProgressBar.h71
1 files changed, 0 insertions, 71 deletions
diff --git a/utils/optimin/src/ProgressBar.h b/utils/optimin/src/ProgressBar.h
deleted file mode 100644
index 9b75594b..00000000
--- a/utils/optimin/src/ProgressBar.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Progress bar.
- *
- * Adapted from https://www.bfilipek.com/2020/02/inidicators.html
- */
-
-#pragma once
-
-#include <llvm/ADT/StringRef.h>
-#include <llvm/Support/raw_ostream.h>
-
-/// Display a progress bar in the terminal
-class ProgressBar {
-
- private:
- const size_t BarWidth;
- const std::string Fill;
- const std::string Remainder;
-
- public:
- ProgressBar() : ProgressBar(60, "#", " ") {
-
- }
-
- ProgressBar(size_t Width, const llvm::StringRef F, const llvm::StringRef R)
- : BarWidth(Width), Fill(F), Remainder(R) {
-
- }
-
- void update(float Progress, const llvm::StringRef Status = "",
- llvm::raw_ostream &OS = llvm::outs()) {
-
- // No need to write once progress is 100%
- if (Progress > 100.0f) return;
-
- // Move cursor to the first position on the same line and flush
- OS << '\r';
- OS.flush();
-
- // Start bar
- OS << '[';
-
- const auto Completed =
- static_cast<size_t>(Progress * static_cast<float>(BarWidth) / 100.0);
- for (size_t I = 0; I < BarWidth; ++I) {
-
- if (I <= Completed) {
-
- OS << Fill;
-
- } else {
-
- OS << Remainder;
-
- }
-
- }
-
- // End bar
- OS << ']';
-
- // Write progress percentage
- OS << ' ' << std::min(static_cast<size_t>(Progress), size_t(100)) << '%';
-
- // Write status text
- OS << " " << Status;
-
- }
-
-};
-