Skip to content

Commit

Permalink
perf report: Use timestamp__scnprintf_nsec() for time sort key
Browse files Browse the repository at this point in the history
Use timestamp__scnprintf_nsec() to print nanoseconds for the time sort
key, instead of open coding.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20190823210338.12360-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Andi Kleen authored and Arnaldo Carvalho de Melo committed Aug 26, 2019
1 parent b4de344 commit 092804a
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions tools/perf/util/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,17 +670,11 @@ sort__time_cmp(struct hist_entry *left, struct hist_entry *right)
static int hist_entry__time_snprintf(struct hist_entry *he, char *bf,
size_t size, unsigned int width)
{
unsigned long secs;
unsigned long long nsecs;
char he_time[32];

nsecs = he->time;
secs = nsecs / NSEC_PER_SEC;
nsecs -= secs * NSEC_PER_SEC;

if (symbol_conf.nanosecs)
snprintf(he_time, sizeof he_time, "%5lu.%09llu: ",
secs, nsecs);
timestamp__scnprintf_nsec(he->time, he_time,
sizeof(he_time));
else
timestamp__scnprintf_usec(he->time, he_time,
sizeof(he_time));
Expand Down

0 comments on commit 092804a

Please sign in to comment.