Skip to content

Commit f371102

Browse files
committed
perf time-utils: Adopt rdclock() from perf.h
Seems to be a better place for this function to live, further shrinking the hodge-podge that perf.h was. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-0zzt1u9rpyjukdy1ccr2u5r9@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 91854f9 commit f371102

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

‎tools/perf/builtin-stat.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include "util/string2.h"
6363
#include "util/metricgroup.h"
6464
#include "util/target.h"
65+
#include "util/time-utils.h"
6566
#include "util/top.h"
6667
#include "asm/bug.h"
6768

‎tools/perf/perf.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,8 @@
22
#ifndef _PERF_PERF_H
33
#define _PERF_PERF_H
44

5-
#include <time.h>
65
#include <stdbool.h>
76

8-
static inline unsigned long long rdclock(void)
9-
{
10-
struct timespec ts;
11-
12-
clock_gettime(CLOCK_MONOTONIC, &ts);
13-
return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
14-
}
15-
167
#ifndef MAX_NR_CPUS
178
#define MAX_NR_CPUS 2048
189
#endif

‎tools/perf/util/event.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "strlist.h"
2222
#include "thread.h"
2323
#include "thread_map.h"
24+
#include "time-utils.h"
2425
#include <linux/ctype.h>
2526
#include "map.h"
2627
#include "symbol.h"

‎tools/perf/util/time-utils.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _TIME_UTILS_H_
44

55
#include <stddef.h>
6+
#include <time.h>
67
#include <linux/types.h>
78

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

3536
int fetch_current_timestamp(char *buf, size_t sz);
3637

38+
static inline unsigned long long rdclock(void)
39+
{
40+
struct timespec ts;
41+
42+
clock_gettime(CLOCK_MONOTONIC, &ts);
43+
return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
44+
}
45+
3746
#endif

0 commit comments

Comments
 (0)