Thread Perl time() und eine microtime(): Wie kann man microtime() im Perl (8 answers)
Opened by polkana at 2005-09-02 19:01

polkana
 2005-09-03 03:29
#57591 #57591
User since
2004-06-18
74 Artikel
BenutzerIn
[Homepage] [default_avatar]
Example 1;
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/perl
use Time::HiRes qw(gettimeofday tv_interval);
my $t = [gettimeofday];
for( 0 .. 1000000 )
{
$str = "Im a TEST: 1, 2, 5;";
$str =~ s/\W+//g;
}

print "Content-type: text/html\n\n";
print "Time passed: ", tv_interval($t);

Time passed: 4.417454
...........................
Example 2;
Code: (dl )
1
2
3
4
5
6
7
8
9
my $start = (times)[0];
for( 0 .. 1000000 )
{
$str = "Im a TEST: 1, 2, 5;";
$str =~ s/\W+//g;
}
my $result = (times)[0]-$start;
print "Content-type: text/html\n\n";
print "Time passed: $result";

Time passed: 4.3828125
.................................\n\n

<!--EDIT|polkana|1125703903-->

View full thread Perl time() und eine microtime(): Wie kann man microtime() im Perl