#!/usr/bin/perl -- use strict; use warnings; use Benchmark qw(cmpthese); my $BIG = 100_000; cmpthese(1000, { 'C-style' => \&c, 'P-style' => \&p}); sub c { for (my $i = $BIG; $i > 0; $i--) { 1; } } sub p { for my $i ( reverse 1..$BIG ) { 1; } } __END__ Rate P-style C-style P-style 26.7/s -- -44% C-style 48.0/s 80% --
Is Perl-style still better?
In reply to Re^5: C-style for loop
by ccn
in thread C-style for loop
by mandog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |