#!/usr/bin/perl -w # # range-perf Extract a time range from Linux "perf script" output. # # USAGE EXAMPLE: # # perf record -F 100 -a -- sleep 60 # perf script | ./perf2range.pl 10 20 # range 10 to 20 seconds only # perf script | ./perf2range.pl 0 0.5 # first half second only # # MAKING A SERIES OF FLAME GRAPHS: # # Let's say you had the output of "perf script" in a file, out.stacks01, which # was for a 180 second profile. The following command creates a series of # flame graphs for each 10 second interval: # # for i in `seq 0 10 170`; do cat out.stacks01 | \ # ./perf2range.pl $i $((i + 10)) | ./stackcollapse-perf.pl | \ # grep -v cpu_idle | ./flamegraph.pl --hash --color=java \ # --title="range $i $((i + 10))" > out.range_$i.svg; echo $i done; done # # In that example, I used "--color=java" for the Java palette, and excluded # the idle CPU task. Customize as needed. # # Copyright 2017 Netflix, Inc. # Licensed under the Apache License, Version 2.0 (the "License") # # 21-Feb-2017 Brendan Gregg Created this.
use strict;
use Getopt::Long;
use POSIX 'floor';
sub usage {
die <<USAGE_END;
USAGE: $0 [options] min_seconds max_seconds
--timeraw # use raw timestamps from perf
--timezerosecs # time starts at 0 secs, but keep offset from perf
eg,
$0 10 20 # only include samples between 10 and 20 seconds
USAGE_END
}
my $timeraw = 0;
my $timezerosecs = 0;
GetOptions( 'timeraw' => \$timeraw, 'timezerosecs' => \$timezerosecs,
) or usage();
if (@ARGV < 2 || $ARGV[0] eq "-h" || $ARGV[0] eq "--help") {
usage();
exit;
}
my $begin = $ARGV[0];
my $end = $ARGV[1];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.