MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / progress

Function progress

examples/common/progress.h:16–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include <cmath>
15
16static bool progress(unsigned iter_curr, af::timer t, double time_total) {
17 static unsigned iter_prev = 0;
18 static double time_prev = 0;
19 static double max_rate = 0;
20
21 af::sync();
22 double time_curr = af::timer::stop(t);
23
24 if ((time_curr - time_prev) < 1) return true;
25
26 double rate = (iter_curr - iter_prev) / (time_curr - time_prev);
27 printf(" iterations per second: %.0f (progress %.0f%%)\n", rate,
28 100.0f * time_curr / time_total);
29
30 max_rate = std::max(max_rate, rate);
31
32 iter_prev = iter_curr;
33 time_prev = time_curr;
34
35 if (time_curr < time_total) return true;
36
37 printf(" ### %f iterations per second (max)\n", max_rate);
38 return false;
39}
40
41#endif

Callers 1

brain_segFunction · 0.85

Calls 2

syncFunction · 0.50
maxFunction · 0.50

Tested by

no test coverage detected