#! perl -slw use 5.010; use strict; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'END_C', NAME => '_842899', CLEAN_AFTER_BUILD => 0; void sumEm( SV *acc, SV *SoS, SV *in, int n ) { int *iAcc = (int*)SvPVX( acc ); int *iIn = (int*)SvPVX( in ); int *iSoS = (int*)SvPVX( SoS ); int i; for( i=0; i < n; ++i ) { iAcc[ i ] += iIn[ i ]; iSoS[ i ] += iIn[ i ] * iIn[ i ]; } } END_C use Time::HiRes qw[ time ]; my $start = time; my $acc = chr(0) x 4e6; my $sos = $acc; open I, '<:raw', 'cells' or die $!; while( sysread( I, my $row, 4e6 ) ) { sumEm( $acc, $sos, $row, 1e6 ); } close I; printf "Took: %.6f seconds\n", time() - $start; ; my @sums = unpack 'V*', $acc; my @SoSs = unpack 'V*', $sos; print "$sums[ $_ ] : $SoSs[ $_ ]" for 0 .. $#sums; __END__ C:\test>842899.pl Took: 39.318000 seconds