MCPcopy Create free account
hub / github.com/SeisSol/SeisSol / loadBar

Function loadBar

preprocessing/meshing/cube_c/src/main.cpp:114–144  ·  view source on GitHub ↗

Process has done i out of n rounds, and we want a bar of width w and resolution r. TODO put this i an library

Source from the content-addressed store, hash-verified

112// and we want a bar of width w and resolution r.
113// TODO put this i an library
114static inline void loadBar(int x, int n, int r = 100, int w = 50)
115{
116 r = std::min(r, n);
117
118 // Only update r times.
119 if ( x % (n/r) != 0 ) return;
120
121 // Calculuate the ratio of complete-to-incomplete.
122 float ratio = x/(float)n;
123 int c = ratio * w;
124
125 // Show the percentage complete.
126 std::cout << std::setw(3) << (int)(ratio*100) << "% [";
127
128 // Show the load bar.
129 for (int x=0; x<c; x++)
130 std::cout << '=';
131
132 for (int x=c; x<w; x++)
133 std::cout << ' ';
134
135 std::cout << ']';
136
137 if (x != n)
138 // go to the beginning of the line
139 std::cout << '\r';
140 else
141 std::cout << '\n';
142
143 std::cout << std::flush;
144}
145
146static const char* dim2str(unsigned int dim)
147{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected