The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Text::Xslate::PP - Yet another Text::Xslate runtime in pure Perl

VERSION

This document describes Text::Xslate::PP version 0.2014.

DESCRIPTION

This module implements Text::Xslate runtime engine in pure Perl. Normally it will be loaded if it fails to load XS. So you do not need to use this module explicitly.

    # Text::Xslate loads PP if needed
    use Text::Xslate;
    my $tx = Text::Xslate->new();

If you want to use Text::Xslate::PP, however, you can use it.

    use Text::Xslate::PP;
    my $tx = Text::Xslate->new();

XS/PP mode might be switched with $ENV{XSLATE} = 'pp' or 'xs'.

From 0.1024 on, there are two pure Perl engines. Text::Xslate::PP::Booster, enabled by $ENV{XSLATE} = 'pp=booster', generates optimized Perl code from intermediate code. Text::Xslate::PP::Opcode, enabled by $ENV{XSLATE} = 'pp=opcode', executes intermediate code directly, emulating the virtual machine in pure Perl.

PP::Booster is much faster than PP::Opcode, but it may be less stable. The default pure Perl engine is PP::Booster, so if you run into problems, please try $ENV{XSLATE} = 'pp=opcode'.

$ENV{XSLATE} = 'pp=verbose' } may be useful for debugging.

NOTE

Performance

There might be cases where you cannot use XS modules.

Here is a result of benchmark/x-poor-env.pl to compare pure Perl template engines in poor environment where applications runs as CGI scripts and XS modules are not available.

    $ perl -Mblib benchmark/x-poor-env.pl
    Perl/5.10.1 i686-linux
    Xslate backend: Booster
    Text::Xslate/0.1058
    Template/2.22
    HTML::Template/2.9
    Text::MicroTemplate/0.15
    Text::MicroTemplate::Extended/0.11
    1..3
    ok 1 - TT: Template-Toolkit
    ok 2 - MT: Text::MicroTemplate
    ok 3 - HT: HTML::Template
    Benchmarks with 'include' (datasize=100)
             Rate     TT     HT Xslate     MT
    TT     76.1/s     --   -60%   -61%   -82%
    HT      189/s   149%     --    -3%   -56%
    Xslate  196/s   158%     4%     --   -54%
    MT      429/s   463%   126%   118%     --

According to this result, PP::Booster is over 2 times faster than Template::Toolkit, and as fast as HTML::Template, but slower than Text::MicroTemplate.

SEE ALSO

Text::Xslate

Text::Xslate::PP::Opcode

Text::Xslate::PP::Booster

AUTHOR

Text::Xslate::PP stuff is originally written by Makamaka Hannyaharamitu <makamaka at cpan.org>, and also maintained by Fuji, Goro (gfx).

LICENSE AND COPYRIGHT

Copyright (c) 2010 by Makamaka Hannyaharamitu (makamaka).

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.