diff options
Diffstat (limited to 'tools/perf/ui/progress.c')
-rw-r--r-- | tools/perf/ui/progress.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c index 3ec695607a4d..a0f24c7115c5 100644 --- a/tools/perf/ui/progress.c +++ b/tools/perf/ui/progress.c | |||
@@ -1,26 +1,38 @@ | |||
1 | #include "../cache.h" | 1 | #include "../cache.h" |
2 | #include "progress.h" | 2 | #include "progress.h" |
3 | 3 | ||
4 | static void nop_progress_update(u64 curr __maybe_unused, | 4 | static void null_progress__update(struct ui_progress *p __maybe_unused) |
5 | u64 total __maybe_unused, | ||
6 | const char *title __maybe_unused) | ||
7 | { | 5 | { |
8 | } | 6 | } |
9 | 7 | ||
10 | static struct ui_progress default_progress_fns = | 8 | static struct ui_progress_ops null_progress__ops = |
11 | { | 9 | { |
12 | .update = nop_progress_update, | 10 | .update = null_progress__update, |
13 | }; | 11 | }; |
14 | 12 | ||
15 | struct ui_progress *progress_fns = &default_progress_fns; | 13 | struct ui_progress_ops *ui_progress__ops = &null_progress__ops; |
16 | 14 | ||
17 | void ui_progress__update(u64 curr, u64 total, const char *title) | 15 | void ui_progress__update(struct ui_progress *p, u64 adv) |
18 | { | 16 | { |
19 | return progress_fns->update(curr, total, title); | 17 | p->curr += adv; |
18 | |||
19 | if (p->curr >= p->next) { | ||
20 | p->next += p->step; | ||
21 | ui_progress__ops->update(p); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | void ui_progress__init(struct ui_progress *p, u64 total, const char *title) | ||
26 | { | ||
27 | p->curr = 0; | ||
28 | p->next = p->step = total / 16; | ||
29 | p->total = total; | ||
30 | p->title = title; | ||
31 | |||
20 | } | 32 | } |
21 | 33 | ||
22 | void ui_progress__finish(void) | 34 | void ui_progress__finish(void) |
23 | { | 35 | { |
24 | if (progress_fns->finish) | 36 | if (ui_progress__ops->finish) |
25 | progress_fns->finish(); | 37 | ui_progress__ops->finish(); |
26 | } | 38 | } |