Skip to content

Commit ec0d3d1

Browse files
olsajiriacmel
authored andcommitted
perf stat: Move 'interval' into struct perf_stat_config
Moving 'interval' into struct perf_stat_config. The point is to centralize the base stat config so it could be used localy together with other stat routines in other parts of perf code. Signed-off-by: Jiri Olsa <[email protected]> Cc: David Ahern <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 5821522 commit ec0d3d1

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

tools/perf/builtin-stat.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ static bool group = false;
113113
static const char *pre_cmd = NULL;
114114
static const char *post_cmd = NULL;
115115
static bool sync_run = false;
116-
static unsigned int interval = 0;
117116
static unsigned int initial_delay = 0;
118117
static unsigned int unit_width = 4; /* strlen("unit") */
119118
static bool forever = false;
@@ -404,6 +403,7 @@ static void workload_exec_failed_signal(int signo __maybe_unused, siginfo_t *inf
404403

405404
static int __run_perf_stat(int argc, const char **argv)
406405
{
406+
int interval = stat_config.interval;
407407
char msg[512];
408408
unsigned long long t0, t1;
409409
struct perf_evsel *counter;
@@ -646,7 +646,7 @@ static void nsec_printout(int id, int nr, struct perf_evsel *evsel, double avg)
646646
if (evsel->cgrp)
647647
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
648648

649-
if (csv_output || interval)
649+
if (csv_output || stat_config.interval)
650650
return;
651651

652652
if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
@@ -689,7 +689,7 @@ static void abs_printout(int id, int nr, struct perf_evsel *evsel, double avg)
689689
if (evsel->cgrp)
690690
fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
691691

692-
if (csv_output || interval)
692+
if (csv_output || stat_config.interval)
693693
return;
694694

695695
perf_stat__print_shadow_stats(output, evsel, avg, cpu,
@@ -990,6 +990,7 @@ static void print_footer(void)
990990

991991
static void print_counters(struct timespec *ts, int argc, const char **argv)
992992
{
993+
int interval = stat_config.interval;
993994
struct perf_evsel *counter;
994995
char buf[64], *prefix = NULL;
995996

@@ -1029,7 +1030,7 @@ static volatile int signr = -1;
10291030

10301031
static void skip_signal(int signo)
10311032
{
1032-
if ((child_pid == -1) || interval)
1033+
if ((child_pid == -1) || stat_config.interval)
10331034
done = 1;
10341035

10351036
signr = signo;
@@ -1313,7 +1314,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
13131314
"command to run prior to the measured command"),
13141315
OPT_STRING(0, "post", &post_cmd, "command",
13151316
"command to run after to the measured command"),
1316-
OPT_UINTEGER('I', "interval-print", &interval,
1317+
OPT_UINTEGER('I', "interval-print", &stat_config.interval,
13171318
"print counts at regular interval in ms (>= 100)"),
13181319
OPT_SET_UINT(0, "per-socket", &stat_config.aggr_mode,
13191320
"aggregate counts per processor socket", AGGR_SOCKET),
@@ -1332,6 +1333,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
13321333
int status = -EINVAL, run_idx;
13331334
const char *mode;
13341335
FILE *output = stderr;
1336+
unsigned int interval;
13351337

13361338
setlocale(LC_ALL, "");
13371339

@@ -1342,6 +1344,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
13421344
argc = parse_options(argc, argv, options, stat_usage,
13431345
PARSE_OPT_STOP_AT_NON_OPTION);
13441346

1347+
interval = stat_config.interval;
1348+
13451349
if (output_name && strcmp(output_name, "-"))
13461350
output = NULL;
13471351

tools/perf/util/stat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct perf_stat_config {
5454
enum aggr_mode aggr_mode;
5555
bool scale;
5656
FILE *output;
57+
unsigned int interval;
5758
};
5859

5960
static inline struct perf_counts_values*

0 commit comments

Comments
 (0)