diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-10-23 14:40:38 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-10-23 14:40:38 -0400 |
commit | 4d3001fdfdfacd2b35ee74ff0f037274eeebd3f6 (patch) | |
tree | 20634d8528fe514298163af38a66b37447503926 /tools/perf/ui/progress.c | |
parent | 4779a2e99af80e133ee1c70c7093dc6cc13429a1 (diff) |
perf ui progress: Per progress bar state
That will ease using a progress bar across multiple functions, like in
the upcoming patches that will present a progress bar when collapsing
histograms.
Based on a previous patch by Namhyung Kim.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-cr7lq7ud9fj21bg7wvq27w1u@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/progress.c')
-rw-r--r-- | tools/perf/ui/progress.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/perf/ui/progress.c b/tools/perf/ui/progress.c index d753821b6e0b..a0f24c7115c5 100644 --- a/tools/perf/ui/progress.c +++ b/tools/perf/ui/progress.c | |||
@@ -1,9 +1,7 @@ | |||
1 | #include "../cache.h" | 1 | #include "../cache.h" |
2 | #include "progress.h" | 2 | #include "progress.h" |
3 | 3 | ||
4 | static void null_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 | ||
@@ -14,9 +12,23 @@ static struct ui_progress_ops null_progress__ops = | |||
14 | 12 | ||
15 | struct ui_progress_ops *ui_progress__ops = &null_progress__ops; | 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 ui_progress__ops->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) |