Commit 435b46ef authored by Song Liu's avatar Song Liu Committed by Arnaldo Carvalho de Melo

perf stat: Measure 't0' and 'ref_time' after enable_counters()

Take measurements of 't0' and 'ref_time' after enable_counters(), so
that they only measure the time consumed when the counters are enabled.
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
Acked-by: default avatarAndi Kleen <andi@firstfloor.org>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: kernel-team@fb.com
Link: http://lore.kernel.org/lkml/20210316211837.910506-3-songliubraving@fb.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 7fac83aa
......@@ -931,15 +931,15 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
/*
* Enable counters and exec the command:
*/
t0 = rdclock();
clock_gettime(CLOCK_MONOTONIC, &ref_time);
if (forks) {
evlist__start_workload(evsel_list);
err = enable_counters();
if (err)
return -1;
t0 = rdclock();
clock_gettime(CLOCK_MONOTONIC, &ref_time);
if (interval || timeout || evlist__ctlfd_initialized(evsel_list))
status = dispatch_events(forks, timeout, interval, &times);
if (child_pid != -1) {
......@@ -960,6 +960,10 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
err = enable_counters();
if (err)
return -1;
t0 = rdclock();
clock_gettime(CLOCK_MONOTONIC, &ref_time);
status = dispatch_events(forks, timeout, interval, &times);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment