Skip to content

Commit

Permalink
perf time-utils: Adopt rdclock() from perf.h
Browse files Browse the repository at this point in the history
Seems to be a better place for this function to live, further shrinking
the hodge-podge that perf.h was.

Cc: Adrian Hunter <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Aug 29, 2019
1 parent 91854f9 commit f371102
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "util/string2.h"
#include "util/metricgroup.h"
#include "util/target.h"
#include "util/time-utils.h"
#include "util/top.h"
#include "asm/bug.h"

Expand Down
9 changes: 0 additions & 9 deletions tools/perf/perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,8 @@
#ifndef _PERF_PERF_H
#define _PERF_PERF_H

#include <time.h>
#include <stdbool.h>

static inline unsigned long long rdclock(void)
{
struct timespec ts;

clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
}

#ifndef MAX_NR_CPUS
#define MAX_NR_CPUS 2048
#endif
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "strlist.h"
#include "thread.h"
#include "thread_map.h"
#include "time-utils.h"
#include <linux/ctype.h>
#include "map.h"
#include "symbol.h"
Expand Down
9 changes: 9 additions & 0 deletions tools/perf/util/time-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define _TIME_UTILS_H_

#include <stddef.h>
#include <time.h>
#include <linux/types.h>

struct perf_time_interval {
Expand Down Expand Up @@ -34,4 +35,12 @@ int timestamp__scnprintf_nsec(u64 timestamp, char *buf, size_t sz);

int fetch_current_timestamp(char *buf, size_t sz);

static inline unsigned long long rdclock(void)
{
struct timespec ts;

clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
}

#endif

0 comments on commit f371102

Please sign in to comment.