- or download this
@new_list =
map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [ $_, expensive_function( $_ ) ] }
@old_list;
- or download this
a_bunch_of_random_letters|19670620|and_some_more_random_letters
- or download this
sub get_date_perl
{
my $date = substr( $_[0], index( $_[0], '|' ) + 1, 8 );
return join '', unpack( "A4A2A2",$date );
}
- or download this
SV* get_date( char* str )
{
/* some stuff goes here */
return newSVpv(date,8);
}
- or download this
#!/usr/bin/perl -w
use strict;
...
return newSVpv( date, 8 );
}
END_OF_C_CODE
- or download this
my $date = get_date( $string );
- or download this
sub get_date_perl
{
...
my ( $month, $day, $year ) = unpack( "A2A2A4",$date );
return $year.$month.$day;
}
- or download this
SV* get_date (char* str)
{
...
new_date[7] = date[3];
return newSVpv(new_date,8);
}
- or download this
Benchmark: timing 50 iterations of Inline, Perl...
Inline: 41 wallclock secs (40.72 usr + 0.00 sys = 40.72 CPU) @ 1
+.23/s (n=50)
Perl: 53 wallclock secs (53.21 usr + 0.00 sys = 53.21 CPU) @ 0
+.94/s (n=50)
- or download this
@new_list =
map_sort { $a->[1] <=> $b->[1] }
map { [ $_, expensive_function( $_ ) ] }
@old_list;
- or download this
Benchmark: timing 50 iterations of Inline, Ovidian, Perl...
Inline: 41 wallclock secs (40.72 usr + 0.00 sys = 40.72 CPU) @ 1
+.23/s (n=50)
Ovidian: 34 wallclock secs (34.71 usr + 0.00 sys = 34.71 CPU) @ 1
+.44/s (n=50)
Perl: 53 wallclock secs (53.21 usr + 0.00 sys = 53.21 CPU) @ 0
+.94/s (n=50)
- or download this
#!/usr/bin/perl -w
use strict;
...
new_date[7] = date[3];
return newSVpv(new_date,8);
}