SPUG: "Programming Challenge"
Yitzchak Scott-Thoennes
sthoenna at efn.org
Thu Dec 18 02:08:03 CST 2003
On Wed, Dec 17, 2003 at 11:00:56PM -0800, David Dyck <david.dyck at fluke.com> wrote:
> use Encode;
> sub block_size { 0x2000 };
> for (my $i=0; $i < length $LSB; $i+= block_size ) {
> syswrite STDOUT, encode("UCS-2LE", substr($LSB, $i, block_size ))
> ^ encode("UCS-2BE", substr($MSB, $i, block_size ));
> }
>
> I'm not sure how the original $LSB and $MSB were being read in, but
> it might have been good to read it in by a similar chunk to use less RAM.
>
> It was educational to look into the Encode module, as
> it looks like the .xs (C) implementation of encode is specialized version
> of pack, even using the "v" and "n" characters for endian flags.
>
> My thanks to Yitzchak and Ross for this learning opportunity,
> David
I'm curious to know if you experimented with different block sizes.
I'd guess its not swapping but cpu cache that is the issue.
More information about the spug-list
mailing list