mirror of
http://mpg123.de/trunk/.git
synced 2025-08-06 10:02:38 +03:00
update the CPU benchmark... producing some formatted text output (for plotting, for example)
git-svn-id: svn://scm.orgis.org/mpg123/trunk@2001 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
@@ -2,23 +2,25 @@
|
|||||||
#
|
#
|
||||||
# benchmark-cpu.pl: benchmark CPU optimisations of mpg123
|
# benchmark-cpu.pl: benchmark CPU optimisations of mpg123
|
||||||
#
|
#
|
||||||
# written by Nicholas J Humfrey <njh@aelius.com>, placed in the public domain
|
# initially written by Nicholas J Humfrey <njh@aelius.com>, placed in the public domain
|
||||||
#
|
#
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Time::HiRes qw/time/;
|
#use Time::HiRes qw/time/;
|
||||||
|
|
||||||
my $MPG123_CMD = '../src/mpg123';
|
my $MPG123_CMD = shift @ARGV;
|
||||||
my $TEST_FILE = $ARGV[0];
|
my @TEST_FILES = @ARGV;
|
||||||
|
|
||||||
die "Please specify a test MP3 file to decode" if (scalar(@ARGV) < 1);
|
die "Please specify full path to mpg123 >= 1.7.0 and a test MP3 file to decode" if (scalar(@ARGV) < 1);
|
||||||
die "mpg123 command does not exist" unless (-e $MPG123_CMD);
|
die "mpg123 command does not exist" unless (-e $MPG123_CMD);
|
||||||
die "mpg123 command is not executable" unless (-x $MPG123_CMD);
|
die "mpg123 command is not executable" unless (-x $MPG123_CMD);
|
||||||
die "test MP3 file does not exist" unless (-e $TEST_FILE);
|
for(@TEST_FILES)
|
||||||
|
{
|
||||||
|
die "test MP3 file does not exist" unless (-e $_);
|
||||||
|
}
|
||||||
|
|
||||||
# Force unbuffed output on STDOUT
|
# Force unbuffed output on STDOUT
|
||||||
$|=1;
|
#$|=1; # why?
|
||||||
|
|
||||||
# Check the CPUs available
|
# Check the CPUs available
|
||||||
my $cpulist = `$MPG123_CMD --test-cpu`;
|
my $cpulist = `$MPG123_CMD --test-cpu`;
|
||||||
@@ -26,18 +28,29 @@ chomp( $cpulist );
|
|||||||
die "Failed to get list of available CPU optimisations" unless ($cpulist =~ s/^Supported decoders: //);
|
die "Failed to get list of available CPU optimisations" unless ($cpulist =~ s/^Supported decoders: //);
|
||||||
|
|
||||||
my @cpus = split( / /, $cpulist );
|
my @cpus = split( / /, $cpulist );
|
||||||
printf("Found %d CPU optimisations to test...\n\n", scalar(@cpus) );
|
my @encs = qw(s16 f32);
|
||||||
|
|
||||||
foreach my $cpu (@cpus) {
|
printf STDERR ("Found %d CPU optimisations to test...\n\n", scalar(@cpus) );
|
||||||
print "Checking speed of $cpu optimisation: ";
|
|
||||||
|
|
||||||
my $start_time = time();
|
|
||||||
system( $MPG123_CMD, '-q', '--cpu', $cpu, '-t', $TEST_FILE );
|
|
||||||
my $end_time = time();
|
|
||||||
|
|
||||||
printf("%4.4f seconds\n", $end_time - $start_time );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
print "#mpg123 benchmark (user CPU time in seconds for decoding)\n";
|
||||||
|
print "#decoder";
|
||||||
|
for(@encs){ print " t_$_/s"; }
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
|
foreach my $cpu (@cpus)
|
||||||
|
{
|
||||||
|
print "$cpu";
|
||||||
|
foreach my $e (@encs)
|
||||||
|
{
|
||||||
|
# using user CPU time
|
||||||
|
my @start_time = times();
|
||||||
|
system($MPG123_CMD, '-q', '--cpu', $cpu, '-e', $e, '-t', @TEST_FILES );
|
||||||
|
my @end_time = times();
|
||||||
|
|
||||||
|
# third entry is child user time
|
||||||
|
printf(" %4.2f", $end_time[2] - $start_time[2]);
|
||||||
|
}
|
||||||
|
print("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user