www.pudn.com > sphinx_recipe.zip > TimeJob.pl
#!/usr/bin/perl
# Script to time how long some recognition job takes.
#
# Only times down to 1 second accuracy. Can optionally
# compute a factor versus some reference time (for example
# the time of the audio being recognized).
#
# Copyright 2006 by Keith Vertanen
#
use strict;
if ( @ARGV < 2 )
{
print "$0 [compare to time]\n";
exit(1);
}
my $mode;
my $tempFilename;
my $start;
my $end;
my $compareTo;
($mode, $tempFilename, $compareTo) = @ARGV;
if (lc($mode) =~ /start/)
{
open(OUT, ">" . $tempFilename);
print OUT time();
close(OUT);
}
else
{
open(IN, $tempFilename);
$start = ;
close(IN);
$end = time();
print "Start: " . $start . "\n";
print "End: " . $end . "\n";
print "Elapsed time (s): " . ($end - $start) . "\n";
if ($compareTo)
{
print "Factor: " . ($end - $start) / $compareTo . "\n";
}
}