| Image-TextMode-Reader-ANSI-XS documentation | Contained in the Image-TextMode-Reader-ANSI-XS distribution. |
Image::TextMode::Reader::ANSI::XS - Fast ANSI image parsing
# The XS reader will automatically be used instead of the pure-perl version
my $ansi = Image::TextMode::Format::ANSI->new
$ansi->read( shift );
To parse an ANSI file, we use a simple state machine and examine each character individually. This proves to be a little on the slow side in pure-perl form.
This module endeavors to re-implement the parsing in XS/C. The results show a major speed increase; about 25 times faster.
perl Makefile.PL make make test make install
This is an XS-based version of Image::TextMode::Reader::ANSI's method of the same name.
Image::TextMode version 0.15
Image::TextMode::Reader::ANSI::XS version 0.08
Filesize: 75501 bytes
Benchmark: timing 50 iterations of PP, XS...
PP: 42 wallclock secs (40.99 usr + 0.11 sys = 41.10 CPU) @ 1.22/s (n=50)
XS: 2 wallclock secs ( 2.03 usr + 0.05 sys = 2.08 CPU) @ 24.04/s (n=50)
Rate PP XS
PP 1.22/s -- -95%
XS 24.0/s 1876% --
Brian Cassidy <bricas@cpan.org>
Copyright 2009-2011 by Brian Cassidy
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Image-TextMode-Reader-ANSI-XS documentation | Contained in the Image-TextMode-Reader-ANSI-XS distribution. |
package Image::TextMode::Reader::ANSI::XS; use strict; use warnings; use XSLoader; our $VERSION = '0.08'; use base 'Image::TextMode::Reader'; XSLoader::load( 'Image::TextMode::Reader::ANSI::XS', $VERSION );
1;