Test-Parser
view release on metacpan or search on metacpan
scripts/parse_iozone view on Meta::CPAN
"version|V",
"help|h",
"helplong|H",
"man|",
"debug|D=i",
"2d-plot|p",
"3d-plot",
"hist-plot",
"comp-plot|c",
"comp-names|n=s@" => \@opt_comp_names,,
"file-sizes|f=i@" => \@opt_file_sizes,
"record-sizes|r=i@" => \@opt_record_sizes,
"no-summary|N",
) or pod2usage(-verbose => 0, -exitstatus => 0);
version_and_exit() if $opt_version;
pod2usage(-verbose => 0, -exitstatus => 0) if $opt_help;
pod2usage(-verbose => 1, -exitstatus => 0) if $opt_helplong;
@opt_comp_names = split(/,/, join(',', @opt_comp_names));
@opt_file_sizes = split(/,/, join(',', @opt_file_sizes));
@opt_record_sizes = split(/,/, join(',', @opt_record_sizes));
#========================================================================
# Subroutines
#------------------------------------------------------------------------
=head2 version_and_exit()
Displays text describing the version of the script
=cut
sub version_and_exit
{
my $NAME = $0;
my $VERSION = Test::Parser::iozone->VERSION;
print "$NAME. Test::Parser::iozone version $VERSION\n";
print "Copyright (C) 2006 Bryce W. Harrington <bryce\@bryceharrington.org>\n";
print "This program is free software; you can redistribute it and/or\n";
print "modify it under the same terms as Perl itself.\n";
exit(0);
}
sub main {
my @parsers;
if (@ARGV<1) {
push @ARGV, \*STDIN;
}
INPUT: foreach my $input (@ARGV) {
my $retval = Test::Parser::END_OF_RECORD;
my $input_stream;
# If the user has specified multi-record operation, we can't
# rely on T:P:iozone's file open code and must work with
# streams, because we'll be creating multiple T:P:iozone
# objects per file.
# Open the file for streaming
if (ref($input)) {
$input_stream = $input;
warn "Parsing input stream...\n" if $opt_debug>0;
} elsif (-f $input) {
if (! open(FILE, "<$input")) {
warn "Could not open $input for reading: $!\n";
next INPUT;
}
$input_stream = \*FILE;
} else {
warn "Parsing file '$input'...\n" if $opt_debug>0;
}
# Now iterate over the contents of the stream as long as
# there are more records
while ($retval == Test::Parser::END_OF_RECORD){
my $parser = new Test::Parser::iozone
or die "Couldn't create Test::Parser::iozone object\n";
$retval = $parser->parse($input_stream);
# This is a total hack, but we can do better once TRPI is implemented...
if ($opt_hist_plot && !ref($input)
&& $input =~ m#^(.*)/test_output/iozone.log$#) {
my $rundir = $1;
my $profile = "$rundir/run_profile.txt";
my $kernelname = `grep -e ^pkg_file= $profile`;
$kernelname =~ s/^pkg_file=//;
$kernelname =~ s/\.diff$//;
$parser->name($kernelname);
}
if ($retval) {
push @parsers, $parser;
warn "Finished parsing record\n" if $opt_debug>1;
} elsif (!ref($input)) {
warn "Could not parse log file '$input'.\n";
} else {
warn "Could not parse input stream.\n";
}
}
}
# ------------------------------------------------------------
# Generate report(s) from the parsed data
# ------------------------------------------------------------
# Generate basic per-run plots
if ($opt_2d_plot) {
# If multiple files were parsed, only plot the first one
my $p = $parsers[0];
$p->plot_2d();
}
# Generate 3D plots
if ($opt_3d_plot) {
# If multiple files were parsed, only plot the first one
( run in 1.294 second using v1.01-cache-2.11-cpan-d8267643d1d )