Skip to content

Commit c7e399f

Browse files
Zephaniah E. Loss-Cutler-Hulllenb
authored andcommitted
tools/power turbostat: Allow printing header every N iterations
This gives the ability to reprint the header every N iterations, so you can ensure that a scrolling display always has the header visible somewhere on the screen. Signed-off-by: Zephaniah E. Loss-Cutler-Hull <zephaniah@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 0fc521b commit c7e399f

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct timespec interval_ts = { 5, 0 };
4848
unsigned int model_orig;
4949

5050
unsigned int num_iterations;
51+
unsigned int header_iterations;
5152
unsigned int debug;
5253
unsigned int quiet;
5354
unsigned int shown;
@@ -722,6 +723,8 @@ void help(void)
722723
" -l, --list list column headers only\n"
723724
" -n, --num_iterations num\n"
724725
" number of the measurement iterations\n"
726+
" -N, --header_iterations num\n"
727+
" print header every num iterations\n"
725728
" -o, --out file\n"
726729
" create or truncate \"file\" for all output\n"
727730
" -q, --quiet skip decoding system configuration header\n"
@@ -1399,14 +1402,14 @@ void flush_output_stderr(void)
13991402

14001403
void format_all_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
14011404
{
1402-
static int printed;
1405+
static int count;
14031406

1404-
if (!printed || !summary_only)
1407+
if ((!count || (header_iterations && !(count % header_iterations))) || !summary_only)
14051408
print_header("\t");
14061409

14071410
format_counters(&average.threads, &average.cores, &average.packages);
14081411

1409-
printed = 1;
1412+
count++;
14101413

14111414
if (summary_only)
14121415
return;
@@ -6348,6 +6351,7 @@ void cmdline(int argc, char **argv)
63486351
{ "interval", required_argument, 0, 'i' },
63496352
{ "IPC", no_argument, 0, 'I' },
63506353
{ "num_iterations", required_argument, 0, 'n' },
6354+
{ "header_iterations", required_argument, 0, 'N' },
63516355
{ "help", no_argument, 0, 'h' },
63526356
{ "hide", required_argument, 0, 'H' }, // meh, -h taken by --help
63536357
{ "Joules", no_argument, 0, 'J' },
@@ -6429,6 +6433,15 @@ void cmdline(int argc, char **argv)
64296433
exit(2);
64306434
}
64316435
break;
6436+
case 'N':
6437+
header_iterations = strtod(optarg, NULL);
6438+
6439+
if (header_iterations <= 0) {
6440+
fprintf(outf, "iterations %d should be positive number\n",
6441+
header_iterations);
6442+
exit(2);
6443+
}
6444+
break;
64326445
case 's':
64336446
/*
64346447
* --show: show only those specified

0 commit comments

Comments
 (0)