From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung.kim@lge.com>,
LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>,
David Ahern <dsahern@gmail.com>
Subject: [PATCH 8/8] perf ui/tui: Remember last log line for filtering
Date: Thu, 26 Dec 2013 14:38:04 +0900 [thread overview]
Message-ID: <1388036284-32342-9-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1388036284-32342-1-git-send-email-namhyung@kernel.org>
From: Namhyung Kim <namhyung.kim@lge.com>
When updating log window with filter string, no need to search all
logs everytime. Just save the last offset and update from there.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/ui/browsers/log.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/tools/perf/ui/browsers/log.c b/tools/perf/ui/browsers/log.c
index 62343e0578bb..6491c353eef7 100644
--- a/tools/perf/ui/browsers/log.c
+++ b/tools/perf/ui/browsers/log.c
@@ -13,10 +13,11 @@
struct log_browser_data {
unsigned long offset;
u32 alloc;
+ u32 last_log_line;
char filter[64];
};
-static void __log_menu__filter(struct ui_browser *menu, char *filter);
+static void __log_menu__filter(struct ui_browser *menu, char *filter, bool update);
static void ui_browser__file_seek(struct ui_browser *browser __maybe_unused,
off_t offset __maybe_unused,
@@ -61,7 +62,7 @@ static unsigned int ui_browser__file_refresh(struct ui_browser *browser)
if (perf_log.linemap_changed) {
/* update log window with new linemap */
- __log_menu__filter(browser, lbd->filter);
+ __log_menu__filter(browser, lbd->filter, true);
perf_log.linemap_changed = false;
}
@@ -78,14 +79,15 @@ static unsigned int ui_browser__file_refresh(struct ui_browser *browser)
return row;
}
-static void __log_menu__filter(struct ui_browser *menu, char *filter)
+static void __log_menu__filter(struct ui_browser *menu, char *filter, bool update)
{
char buf[1024];
struct log_browser_data *lbd = menu->priv;
off_t *linemap = NULL;
u32 lines = 0;
u32 alloc = 0;
- u32 i;
+ u32 last = 0;
+ u32 i = 0;
if (*filter == '\0') {
linemap = perf_log.linemap;
@@ -93,7 +95,14 @@ static void __log_menu__filter(struct ui_browser *menu, char *filter)
goto out;
}
- for (i = 0; i < perf_log.lines; i++) {
+ if (update) {
+ linemap = menu->entries;
+ lines = menu->nr_entries;
+ alloc = lbd->alloc;
+ last = lbd->last_log_line;
+ }
+
+ for (i = last; i < perf_log.lines; i++) {
fseek(perf_log.fp, perf_log.linemap[i], SEEK_SET);
if (fgets(buf, sizeof(buf), perf_log.fp) == NULL)
goto error;
@@ -120,7 +129,12 @@ out:
BUG_ON(menu->entries == perf_log.linemap);
free(menu->entries);
}
+
lbd->alloc = alloc;
+ lbd->last_log_line = i;
+
+ if (!update)
+ ui_browser__reset_index(menu);
menu->entries = linemap;
ui_browser__update_nr_entries(menu, lines);
@@ -136,7 +150,7 @@ static void log_menu__filter(struct ui_browser *menu, char *filter)
pthread_mutex_lock(&ui__lock);
fgetpos(perf_log.fp, &pos);
- __log_menu__filter(menu, filter);
+ __log_menu__filter(menu, filter, false);
fsetpos(perf_log.fp, &pos);
perf_log.linemap_changed = false;
pthread_mutex_unlock(&ui__lock);
--
1.7.11.7
prev parent reply other threads:[~2013-12-26 5:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-26 5:37 [PATCHSET 0/8] perf tools: A couple of TUI improvements (v3) Namhyung Kim
2013-12-26 5:37 ` [PATCH 1/8] perf ui/tui: Protect windows by ui__lock Namhyung Kim
2014-01-12 18:39 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-26 5:37 ` [PATCH 2/8] perf ui/tui: Split help message for perf top and report Namhyung Kim
2013-12-26 14:05 ` Arnaldo Carvalho de Melo
2013-12-26 14:12 ` Arnaldo Carvalho de Melo
2014-01-12 18:39 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-26 5:37 ` [PATCH 3/8] perf ui/tui: Implement header window Namhyung Kim
2014-01-12 18:39 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-26 5:38 ` [PATCH 4/8] perf tools: Introduce struct perf_log Namhyung Kim
2013-12-26 14:50 ` Arnaldo Carvalho de Melo
2014-01-03 8:23 ` Namhyung Kim
2013-12-26 14:51 ` David Ahern
2014-01-03 8:49 ` Namhyung Kim
2013-12-26 5:38 ` [PATCH 5/8] perf tools: Save message when pr_*() was called Namhyung Kim
2013-12-26 5:38 ` [PATCH 6/8] perf ui/tui: Implement log window Namhyung Kim
2013-12-26 5:38 ` [PATCH 7/8] perf ui/tui: Filter messages in " Namhyung Kim
2013-12-26 5:38 ` Namhyung Kim [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1388036284-32342-9-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®