diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-10-25 11:29:11 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-10-26 11:04:42 -0400 |
commit | ca59bcbceeb7fd412faa35871ec0bd21bdd69229 (patch) | |
tree | 0d83b6f0b28492a978eb7a5ecde93ec9a2e18258 /tools/perf/util | |
parent | 727ab04edbc4767711a7aeff5e00249b267ed4c1 (diff) |
perf ui progress: Reimplement using slang
Just another step in stopping the use of libnewt in perf.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.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-vkb9jh5kkzl5ep3puoatd6an@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/debug.h | 12 | ||||
-rw-r--r-- | tools/perf/util/session.c | 8 | ||||
-rw-r--r-- | tools/perf/util/ui/progress.c | 64 | ||||
-rw-r--r-- | tools/perf/util/ui/progress.h | 7 |
4 files changed, 22 insertions, 69 deletions
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index fd53db47e3de..510adaccba84 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -19,16 +19,8 @@ static inline int ui_helpline__show_help(const char *format __used, va_list ap _ | |||
19 | return 0; | 19 | return 0; |
20 | } | 20 | } |
21 | 21 | ||
22 | static inline struct ui_progress *ui_progress__new(const char *title __used, | 22 | static inline void ui_progress__update(u64 curr __used, u64 total __used, |
23 | u64 total __used) | 23 | const char *title __used) {} |
24 | { | ||
25 | return (struct ui_progress *)1; | ||
26 | } | ||
27 | |||
28 | static inline void ui_progress__update(struct ui_progress *self __used, | ||
29 | u64 curr __used) {} | ||
30 | |||
31 | static inline void ui_progress__delete(struct ui_progress *self __used) {} | ||
32 | #else | 24 | #else |
33 | extern char ui_helpline__last_msg[]; | 25 | extern char ui_helpline__last_msg[]; |
34 | int ui_helpline__show_help(const char *format, va_list ap); | 26 | int ui_helpline__show_help(const char *format, va_list ap); |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 20e011c99a94..91c6442ef966 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -1012,7 +1012,6 @@ int __perf_session__process_events(struct perf_session *session, | |||
1012 | { | 1012 | { |
1013 | u64 head, page_offset, file_offset, file_pos, progress_next; | 1013 | u64 head, page_offset, file_offset, file_pos, progress_next; |
1014 | int err, mmap_prot, mmap_flags, map_idx = 0; | 1014 | int err, mmap_prot, mmap_flags, map_idx = 0; |
1015 | struct ui_progress *progress; | ||
1016 | size_t page_size, mmap_size; | 1015 | size_t page_size, mmap_size; |
1017 | char *buf, *mmaps[8]; | 1016 | char *buf, *mmaps[8]; |
1018 | union perf_event *event; | 1017 | union perf_event *event; |
@@ -1030,9 +1029,6 @@ int __perf_session__process_events(struct perf_session *session, | |||
1030 | file_size = data_offset + data_size; | 1029 | file_size = data_offset + data_size; |
1031 | 1030 | ||
1032 | progress_next = file_size / 16; | 1031 | progress_next = file_size / 16; |
1033 | progress = ui_progress__new("Processing events...", file_size); | ||
1034 | if (progress == NULL) | ||
1035 | return -1; | ||
1036 | 1032 | ||
1037 | mmap_size = session->mmap_window; | 1033 | mmap_size = session->mmap_window; |
1038 | if (mmap_size > file_size) | 1034 | if (mmap_size > file_size) |
@@ -1095,7 +1091,8 @@ more: | |||
1095 | 1091 | ||
1096 | if (file_pos >= progress_next) { | 1092 | if (file_pos >= progress_next) { |
1097 | progress_next += file_size / 16; | 1093 | progress_next += file_size / 16; |
1098 | ui_progress__update(progress, file_pos); | 1094 | ui_progress__update(file_pos, file_size, |
1095 | "Processing events..."); | ||
1099 | } | 1096 | } |
1100 | 1097 | ||
1101 | if (file_pos < file_size) | 1098 | if (file_pos < file_size) |
@@ -1106,7 +1103,6 @@ more: | |||
1106 | session->ordered_samples.next_flush = ULLONG_MAX; | 1103 | session->ordered_samples.next_flush = ULLONG_MAX; |
1107 | flush_sample_queue(session, ops); | 1104 | flush_sample_queue(session, ops); |
1108 | out_err: | 1105 | out_err: |
1109 | ui_progress__delete(progress); | ||
1110 | perf_session__warn_about_errors(session, ops); | 1106 | perf_session__warn_about_errors(session, ops); |
1111 | perf_session_free_sample_buffers(session); | 1107 | perf_session_free_sample_buffers(session); |
1112 | return err; | 1108 | return err; |
diff --git a/tools/perf/util/ui/progress.c b/tools/perf/util/ui/progress.c index d7fc399d36b3..68d2c548abe3 100644 --- a/tools/perf/util/ui/progress.c +++ b/tools/perf/util/ui/progress.c | |||
@@ -1,60 +1,28 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <newt.h> | ||
3 | #include "../cache.h" | 1 | #include "../cache.h" |
4 | #include "progress.h" | 2 | #include "progress.h" |
3 | #include "libslang.h" | ||
4 | #include "ui.h" | ||
5 | #include "browser.h" | ||
5 | 6 | ||
6 | struct ui_progress { | 7 | void ui_progress__update(u64 curr, u64 total, const char *title) |
7 | newtComponent form, scale; | ||
8 | }; | ||
9 | |||
10 | struct ui_progress *ui_progress__new(const char *title, u64 total) | ||
11 | { | ||
12 | struct ui_progress *self = malloc(sizeof(*self)); | ||
13 | |||
14 | if (self != NULL) { | ||
15 | int cols; | ||
16 | |||
17 | if (use_browser <= 0) | ||
18 | return self; | ||
19 | newtGetScreenSize(&cols, NULL); | ||
20 | cols -= 4; | ||
21 | newtCenteredWindow(cols, 1, title); | ||
22 | self->form = newtForm(NULL, NULL, 0); | ||
23 | if (self->form == NULL) | ||
24 | goto out_free_self; | ||
25 | self->scale = newtScale(0, 0, cols, total); | ||
26 | if (self->scale == NULL) | ||
27 | goto out_free_form; | ||
28 | newtFormAddComponent(self->form, self->scale); | ||
29 | newtRefresh(); | ||
30 | } | ||
31 | |||
32 | return self; | ||
33 | |||
34 | out_free_form: | ||
35 | newtFormDestroy(self->form); | ||
36 | out_free_self: | ||
37 | free(self); | ||
38 | return NULL; | ||
39 | } | ||
40 | |||
41 | void ui_progress__update(struct ui_progress *self, u64 curr) | ||
42 | { | 8 | { |
9 | int bar, y; | ||
43 | /* | 10 | /* |
44 | * FIXME: We should have a per UI backend way of showing progress, | 11 | * FIXME: We should have a per UI backend way of showing progress, |
45 | * stdio will just show a percentage as NN%, etc. | 12 | * stdio will just show a percentage as NN%, etc. |
46 | */ | 13 | */ |
47 | if (use_browser <= 0) | 14 | if (use_browser <= 0) |
48 | return; | 15 | return; |
49 | newtScaleSet(self->scale, curr); | ||
50 | newtRefresh(); | ||
51 | } | ||
52 | 16 | ||
53 | void ui_progress__delete(struct ui_progress *self) | 17 | pthread_mutex_lock(&ui__lock); |
54 | { | 18 | y = SLtt_Screen_Rows / 2 - 2; |
55 | if (use_browser > 0) { | 19 | SLsmg_set_color(0); |
56 | newtFormDestroy(self->form); | 20 | SLsmg_draw_box(y, 0, 3, SLtt_Screen_Cols); |
57 | newtPopWindow(); | 21 | SLsmg_gotorc(y++, 1); |
58 | } | 22 | SLsmg_write_string((char *)title); |
59 | free(self); | 23 | SLsmg_set_color(HE_COLORSET_SELECTED); |
24 | bar = ((SLtt_Screen_Cols - 2) * curr) / total; | ||
25 | SLsmg_fill_region(y, 1, 1, bar, ' '); | ||
26 | SLsmg_refresh(); | ||
27 | pthread_mutex_unlock(&ui__lock); | ||
60 | } | 28 | } |
diff --git a/tools/perf/util/ui/progress.h b/tools/perf/util/ui/progress.h index a3820a0beb5b..d9c205b59aa1 100644 --- a/tools/perf/util/ui/progress.h +++ b/tools/perf/util/ui/progress.h | |||
@@ -1,11 +1,8 @@ | |||
1 | #ifndef _PERF_UI_PROGRESS_H_ | 1 | #ifndef _PERF_UI_PROGRESS_H_ |
2 | #define _PERF_UI_PROGRESS_H_ 1 | 2 | #define _PERF_UI_PROGRESS_H_ 1 |
3 | 3 | ||
4 | struct ui_progress; | 4 | #include <../types.h> |
5 | 5 | ||
6 | struct ui_progress *ui_progress__new(const char *title, u64 total); | 6 | void ui_progress__update(u64 curr, u64 total, const char *title); |
7 | void ui_progress__delete(struct ui_progress *self); | ||
8 | |||
9 | void ui_progress__update(struct ui_progress *self, u64 curr); | ||
10 | 7 | ||
11 | #endif | 8 | #endif |