forked from htailor/cpp_progress_bar
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
49 lines (44 loc) · 1.12 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "progress_bar.hpp"
#include <iostream>
#include <thread>
#include <chrono>
int main() {
/// Example 1 ///
{
int n = 100;
ProgressBar bar1(n, "Example 1");
for (int i = 1; i <= n; ++i) {
bar1 += 1;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
/// Example 2 ///
{
int n = 1000;
ProgressBar bar2(n, "Example 2");
bar2.SetFrequencyUpdate(10);
bar2.SetStyle('|','-');
//bar2.SetStyle("\u2588", "-"); for linux
for (int i = 1; i <= n; ++i) {
bar2 += 1;
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
ProgressBar bar3(5);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
++bar3;
std::this_thread::sleep_for(std::chrono::milliseconds(200));
++bar3;
std::this_thread::sleep_for(std::chrono::milliseconds(200));
++bar3;
std::this_thread::sleep_for(std::chrono::milliseconds(200));
++bar3;
std::this_thread::sleep_for(std::chrono::milliseconds(200));
++bar3;
// following tests exception error
std::this_thread::sleep_for(std::chrono::milliseconds(200));
++bar3;
std::this_thread::sleep_for(std::chrono::milliseconds(200));
++bar3;
return 0;
}