From c52af6a4bb9a9c023adab2032778e99caa5fbf78 Mon Sep 17 00:00:00 2001 From: njh Date: Mon, 4 Jun 2007 14:10:29 +0000 Subject: [PATCH] Perl script to benchmark each of mpg123's CPU optimisations git-svn-id: svn://scm.orgis.org/mpg123/trunk@700 35dc7657-300d-0410-a2e5-dc2837fedb53 --- scripts/benchmark-cpu.pl | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 scripts/benchmark-cpu.pl diff --git a/scripts/benchmark-cpu.pl b/scripts/benchmark-cpu.pl new file mode 100755 index 00000000..275ceb2f --- /dev/null +++ b/scripts/benchmark-cpu.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl +# +# benchmark-cpu.pl: benchmark CPU optimisations of mpg123 +# +# written by Nicholas J Humfrey , placed in the public domain +# + +use strict; +use Time::HiRes qw/time/; + +my $MPG123_CMD = '../src/mpg123'; +my $TEST_FILE = $ARGV[0]; + +die "Please specify a test MP3 file to decode" if (scalar(@ARGV) < 1); +die "mpg123 command does not exist" unless (-e $MPG123_CMD); +die "mpg123 command is not executable" unless (-x $MPG123_CMD); +die "test MP3 file does not exist" unless (-e $TEST_FILE); + + +# Force unbuffed output on STDOUT +$|=1; + +# Check the CPUs available +my $cpulist = `$MPG123_CMD --list-cpu`; +chomp( $cpulist ); +die "Failed to get list of available CPU optimisations" unless ($cpulist =~ /^CPU options: /); + +my @cpus = split( / /, substr( $cpulist, 13 ) ); +printf("Found %d CPU optimisations to test...\n\n", scalar(@cpus) ); + +foreach my $cpu (@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 "\n"; +