Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl time with milliseconds

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Im in need of perl code that will return the time with milliseconds im trying to find out how long it takes for my search to find results and I really need milliseconds because its never a seconds to return the result

Thanks in advance for everyone that can help me with this problem
 
Try using the Perl module Bencmark. It produces great results. The following is an example of the Benchmark use:

Code:
#!/usr/local/bin/perl -w
# ------------------------------------------------------------------------
use strict;
use Benchmark;

my $count = 500_000;
my $string = 'Sentence 1.  Sentence 2.  Sentence 3.';
my @tokens;

timethese($count, {
    'split array'   => sub {
                                $count = @tokens = split( /\./, $string );
                           },
    'split into @_' => sub {
                                $count = split( /\./, $string );
                           },
    'using tr'      => sub {
                                $count = ( $string =~ tr/\.// );
                            },
    }
);

print "Done.\n";
Jean Spector
QA Engineer @ mSAFE Ltd.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top