summaryrefslogtreecommitdiff
path: root/tools/perf/bench
diff options
context:
space:
mode:
authorRiccardo Mancini <rickyman7@gmail.com>2021-08-21 12:19:42 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-10-08 17:45:38 +0300
commitc2d4fab01f5e69adbe697c82f35cc31cf200bf93 (patch)
tree9730dc244296a08b790884de1d218ff892e338e1 /tools/perf/bench
parent6bd006c6eb7fdadbe36de84377af4447da4ffabb (diff)
downloadlinux-c2d4fab01f5e69adbe697c82f35cc31cf200bf93.tar.xz
perf test evlist-open-close: Use inline func to convert timeval to usec
This patch introduces a new inline function to convert a timeval to usec. This function will be used also in the next patch. Signed-off-by: Riccardo Mancini <rickyman7@gmail.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/b95035ec4a125355be8ea843f7275c4580da6398.1629490974.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/bench')
-rw-r--r--tools/perf/bench/evlist-open-close.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/perf/bench/evlist-open-close.c b/tools/perf/bench/evlist-open-close.c
index 83e9897c64a1..75a53919126b 100644
--- a/tools/perf/bench/evlist-open-close.c
+++ b/tools/perf/bench/evlist-open-close.c
@@ -25,6 +25,11 @@ static int iterations = 100;
static int nr_events = 1;
static const char *event_string = "dummy";
+static inline u64 timeval2usec(struct timeval *tv)
+{
+ return tv->tv_sec * USEC_PER_SEC + tv->tv_usec;
+}
+
static struct record_opts opts = {
.sample_time = true,
.mmap_pages = UINT_MAX,
@@ -167,7 +172,7 @@ static int bench_evlist_open_close__run(char *evstr)
gettimeofday(&end, NULL);
timersub(&end, &start, &diff);
- runtime_us = diff.tv_sec * USEC_PER_SEC + diff.tv_usec;
+ runtime_us = timeval2usec(&diff);
update_stats(&time_stats, runtime_us);
evlist__delete(evlist);