diff options
author | Charles Baylis <charles.baylis@linaro.org> | 2017-12-12 11:57:31 +0000 |
---|---|---|
committer | Charles Baylis <charles.baylis@linaro.org> | 2017-12-12 11:57:31 +0000 |
commit | a2e93c745a64562c9786b2ce39fdfa1da20205cb (patch) | |
tree | ffcce5c09d75aab5be0af03a078d6ab9f4bddf69 | |
parent | 4a78815bdecfb62a96b35b0d1b926ef122c8162a (diff) |
Test code for detecting sample interval automatically.
Also add support for --sample-frequency (aka --sample-freq) option
to make it easier to specify the sample interval.
-rw-r--r-- | perf-utilization.pl | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/perf-utilization.pl b/perf-utilization.pl index 27c61fc..ed76df6 100644 --- a/perf-utilization.pl +++ b/perf-utilization.pl @@ -12,6 +12,7 @@ while (@ARGV) my $opt = shift; if ($opt =~ /^--report[_-]?interval(=(.*))?$/) { $REPORT_INTERVAL = $2 // shift; } elsif ($opt =~ /^--sample[_-]?interval(=(.*))?$/) { $SAMPLE_INTERVAL = $2 // shift; } + elsif ($opt =~ /^--sample[_-]?freq(?:uency)?(=(.*))?$/) { $SAMPLE_INTERVAL = 1 / ($2 // shift); } elsif ($opt =~ /^--output(=(.*))?$/) { $OUTPUT = $2 // shift; } elsif ($opt =~ /^--input(=(.*))?$/) { $INPUT = $2 // shift; } elsif ($opt =~ /^--perf(=(.*))?$/) { $PERF = $2 // shift; } @@ -22,7 +23,7 @@ die "Must specify --sample-interval" unless defined $SAMPLE_INTERVAL; die "Must specify --input" unless defined $INPUT; my $tmpdir = tempdir( CLEANUP => 1 ); -system(qq("$PERF" script -i "$INPUT" > "$tmpdir/perfscript.out")) and die "perf script failed"; +system(qq("$PERF" script --header -i "$INPUT" > "$tmpdir/perfscript.out")) and die "perf script failed"; my $fh; if (defined $OUTPUT) @@ -40,6 +41,11 @@ my ($max_cpu); while (<INPUT>) { chomp; + if (/^# event : .*{ sample_period, sample_freq } = (\d+)/) + { + my $discovered_interval = 1/$1; + warn "Command line configured interval was $SAMPLE_INTERVAL, but perf.data header has $discovered_interval" if $SAMPLE_INTERVAL != $discovered_interval; + } next unless /\s*(\S+)\s+(\d+)\s+\[0*(\d+)\]\s+(\d+\.\d+):\s+(\d+)\s+(\S+)\s+(\S+)\s+(.*)/; my ($cpu, $time, $where) = ($3, $4, $8); |