mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 15:27:29 +00:00
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>
This commit is contained in:
parent
4779a2e99a
commit
4d3001fdfd
5 changed files with 47 additions and 30 deletions
|
@ -503,13 +503,16 @@ static int flush_sample_queue(struct perf_session *s,
|
|||
struct perf_sample sample;
|
||||
u64 limit = os->next_flush;
|
||||
u64 last_ts = os->last_sample ? os->last_sample->timestamp : 0ULL;
|
||||
unsigned idx = 0, progress_next = os->nr_samples / 16;
|
||||
bool show_progress = limit == ULLONG_MAX;
|
||||
struct ui_progress prog;
|
||||
int ret;
|
||||
|
||||
if (!tool->ordered_samples || !limit)
|
||||
return 0;
|
||||
|
||||
if (show_progress)
|
||||
ui_progress__init(&prog, os->nr_samples, "Processing time ordered events...");
|
||||
|
||||
list_for_each_entry_safe(iter, tmp, head, list) {
|
||||
if (session_done())
|
||||
return 0;
|
||||
|
@ -530,11 +533,9 @@ static int flush_sample_queue(struct perf_session *s,
|
|||
os->last_flush = iter->timestamp;
|
||||
list_del(&iter->list);
|
||||
list_add(&iter->list, &os->sample_cache);
|
||||
if (show_progress && (++idx >= progress_next)) {
|
||||
progress_next += os->nr_samples / 16;
|
||||
ui_progress__update(idx, os->nr_samples,
|
||||
"Processing time ordered events...");
|
||||
}
|
||||
|
||||
if (show_progress)
|
||||
ui_progress__update(&prog, 1);
|
||||
}
|
||||
|
||||
if (list_empty(head)) {
|
||||
|
@ -1285,12 +1286,13 @@ int __perf_session__process_events(struct perf_session *session,
|
|||
u64 file_size, struct perf_tool *tool)
|
||||
{
|
||||
int fd = perf_data_file__fd(session->file);
|
||||
u64 head, page_offset, file_offset, file_pos, progress_next;
|
||||
u64 head, page_offset, file_offset, file_pos;
|
||||
int err, mmap_prot, mmap_flags, map_idx = 0;
|
||||
size_t mmap_size;
|
||||
char *buf, *mmaps[NUM_MMAPS];
|
||||
union perf_event *event;
|
||||
uint32_t size;
|
||||
struct ui_progress prog;
|
||||
|
||||
perf_tool__fill_defaults(tool);
|
||||
|
||||
|
@ -1301,7 +1303,7 @@ int __perf_session__process_events(struct perf_session *session,
|
|||
if (data_size && (data_offset + data_size < file_size))
|
||||
file_size = data_offset + data_size;
|
||||
|
||||
progress_next = file_size / 16;
|
||||
ui_progress__init(&prog, file_size, "Processing events...");
|
||||
|
||||
mmap_size = MMAP_SIZE;
|
||||
if (mmap_size > file_size)
|
||||
|
@ -1356,11 +1358,7 @@ more:
|
|||
head += size;
|
||||
file_pos += size;
|
||||
|
||||
if (file_pos >= progress_next) {
|
||||
progress_next += file_size / 16;
|
||||
ui_progress__update(file_pos, file_size,
|
||||
"Processing events...");
|
||||
}
|
||||
ui_progress__update(&prog, size);
|
||||
|
||||
if (session_done())
|
||||
goto out;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue