File Coverage

blib/lib/Image/TextMode/Reader/ANSI/XS.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Image::TextMode::Reader::ANSI::XS;
2              
3 1     1   754 use strict;
  1         2  
  1         32  
4 1     1   4 use warnings;
  1         2  
  1         31  
5 1     1   6 use XSLoader;
  1         2  
  1         45  
6              
7             our $VERSION = '0.11';
8              
9 1     1   5 use base 'Image::TextMode::Reader';
  1         2  
  1         546  
10              
11             XSLoader::load( 'Image::TextMode::Reader::ANSI::XS', $VERSION );
12              
13             =head1 NAME
14              
15             Image::TextMode::Reader::ANSI::XS - Fast ANSI image parsing
16              
17             =head1 SYNOPSIS
18              
19             # The XS reader will automatically be used instead of the pure-perl version
20             my $ansi = Image::TextMode::Format::ANSI->new
21             $ansi->read( shift );
22              
23             =head1 DESCRIPTION
24              
25             To parse an ANSI file, we use a simple state machine and examine each character
26             individually. This proves to be a little on the slow side in pure-perl form.
27              
28             This module endeavors to re-implement the parsing in XS/C. The results show
29             a major speed increase; about 25 times faster.
30              
31             =head1 INSTALLATION
32              
33             perl Makefile.PL
34             make
35             make test
36             make install
37              
38             =head1 METHODS
39              
40             =head2 _read( $image, $fh, \%options )
41              
42             This is an XS-based version of L<Image::TextMode::Reader::ANSI>'s method of the
43             same name.
44              
45             =head1 BENCHMARK
46              
47             Image::TextMode version 0.22
48             Image::TextMode::Reader::ANSI::XS version 0.09
49             Filesize: 75501 bytes
50             Benchmark: timing 50 iterations of PP, XS...
51             PP: 33 wallclock secs (32.03 usr + 0.01 sys = 32.04 CPU) @ 1.56/s (n=50)
52             XS: 1 wallclock secs ( 1.59 usr + 0.03 sys = 1.62 CPU) @ 30.86/s (n=50)
53             Rate PP XS
54             PP 1.56/s -- -95%
55             XS 30.9/s 1878% --
56              
57             =head1 AUTHOR
58              
59             Brian Cassidy E<lt>bricas@cpan.orgE<gt>
60              
61             =head1 COPYRIGHT AND LICENSE
62              
63             Copyright 2009-2013 by Brian Cassidy
64              
65             This library is free software; you can redistribute it and/or modify
66             it under the same terms as Perl itself.
67              
68             =cut
69              
70             1;