O'Reilly logo

Programmieren mit Perl by Jon Orwant, Tom Christiansen, Larry Wall

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Benchmark

use Benchmark qw(timethese cmpthese timeit countit timestr);

# Sie können Code immer in Form von Strings übergeben:
timethese $count, {
    'Namel' => '...codel...',
    'Name2' => '...code2...',
 };

# Oder über Sübroutinen-Referenzen:
timethese $count, {
    'Name1' => sub { ...codel... },
    'Name2' => sub { ...code2... },
};

cmpthese $count, {
   'Name1' => '...codel...',
   'Name2' => '...code2...',
};

$t = timeit $count, '...code...';
print "$count Codeschleifen benötigten:", timestr($t), "\n";

$t = countit $time, '...code...';
$count = $t->iters;
print "$count Codeschleifen benötigten:", timestr($t), "\n";

Das Benchmark-Modul hilft Ihnen dabei herauszufinden, welcher von verschiedenen möglichen Codes am schnellsten ausgeführt wird. Die Funktion timethese ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required