#!/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 = 1 ; $i <= $BIG ; $i++ ) { 1; } } sub p { for ( 1 .. $BIG ) { 1; } } __END__ Rate C-style P-style C-style 141/s -- -29% P-style 200/s 42% --
In reply to Re^6: C-style for loop
by zwon
in thread C-style for loop
by mandog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |