[PATCH 08/22] perf tools: Implement selected logic for time sort entry

From: Jiri Olsa
Date: Sun Feb 02 2014 - 16:47:11 EST


Display delta time from the selected entry. Implemented
only for the TUI browser.

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Corey Ashford <cjashfor@xxxxxxxxxxxxxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
---
tools/perf/ui/browsers/hists.c | 13 +++++++++++++
tools/perf/util/sort.c | 6 +++---
2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 0f6d515..e26afea 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -27,6 +27,7 @@ struct hist_browser {
bool show_dso;
float min_pcnt;
u64 nr_pcnt_entries;
+ u64 time_base;
};

extern void hist_browser__init_hpp(void);
@@ -819,12 +820,24 @@ static void ui_browser__hists_init_top(struct ui_browser *browser)
}
}

+static void init_time_base(struct hist_browser *hb)
+{
+ struct hists *hists = hb->hists;
+
+ if (hb->time_base)
+ hists->time_base = hb->time_base;
+
+ if (hists->time_base && !hb->time_base)
+ hb->time_base = hists->time_base;
+}
+
static unsigned int hist_browser__refresh(struct ui_browser *browser)
{
unsigned row = 0;
struct rb_node *nd;
struct hist_browser *hb = container_of(browser, struct hist_browser, b);

+ init_time_base(hb);
ui_browser__hists_init_top(browser);

for (nd = browser->top; nd; nd = rb_next(nd)) {
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index b219eaf..381139d 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -90,11 +90,11 @@ sort__time_cmp(struct sort_entry *se __maybe_unused,
return right->time - left->time;
}

-static u64 get_time_base(struct hist_entry *he)
+static u64 get_time_base(struct hist_entry *he, bool selected)
{
struct hists *hists = he->hists;

- if (!hists->time_base)
+ if (!hists->time_base || selected)
hists->time_base = he->time;

return hists->time_base;
@@ -106,7 +106,7 @@ static int hist_entry__time_snprintf(struct sort_entry *se __maybe_unused,
size_t size, unsigned int width)
{
char buf[100];
- u64 time_base = get_time_base(he);
+ u64 time_base = get_time_base(he, selected);
unsigned long time_sec, time_usec;
unsigned long base_sec, base_usec;
long delta_sec, delta_usec;
--
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/