| File | /usr/lib/perl5/vendor_perl/5.10.1/Epoll/View/Latex.pm |
| Statements Executed | 19 |
| Statement Execution Time | 3.33ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 302µs | 65.8ms | Epoll::View::Latex::BEGIN@9 |
| 1 | 1 | 1 | 87µs | 353µs | Epoll::View::Latex::BEGIN@4 |
| 1 | 1 | 1 | 52µs | 66µs | Epoll::View::Latex::BEGIN@3 |
| 1 | 1 | 1 | 50µs | 628µs | Epoll::View::Latex::BEGIN@5 |
| 1 | 1 | 1 | 40µs | 309µs | LaTeX::Driver::hack::BEGIN@76 |
| 0 | 0 | 0 | 0s | 0s | Epoll::View::Latex::enabled |
| 0 | 0 | 0 | 0s | 0s | Epoll::View::Latex::process |
| 0 | 0 | 0 | 0s | 0s | LaTeX::Driver::hack::run_command |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Epoll::View::Latex; | ||||
| 2 | |||||
| 3 | 3 | 90µs | 2 | 80µs | # spent 66µs (52+14) within Epoll::View::Latex::BEGIN@3 which was called
# once (52µs+14µs) by Catalyst::Utils::ensure_class_loaded at line 3 # spent 66µs making 1 call to Epoll::View::Latex::BEGIN@3
# spent 14µs making 1 call to strict::import |
| 4 | 3 | 90µs | 2 | 620µs | # spent 353µs (87+267) within Epoll::View::Latex::BEGIN@4 which was called
# once (87µs+267µs) by Catalyst::Utils::ensure_class_loaded at line 4 # spent 353µs making 1 call to Epoll::View::Latex::BEGIN@4
# spent 266µs making 1 call to base::import |
| 5 | 3 | 309µs | 2 | 1.21ms | # spent 628µs (50+578) within Epoll::View::Latex::BEGIN@5 which was called
# once (50µs+578µs) by Catalyst::Utils::ensure_class_loaded at line 5 # spent 628µs making 1 call to Epoll::View::Latex::BEGIN@5
# spent 578µs making 1 call to Exporter::import |
| 6 | |||||
| 7 | 1 | 2µs | my $enable = 0; | ||
| 8 | |||||
| 9 | # spent 65.8ms (302µs+65.5) within Epoll::View::Latex::BEGIN@9 which was called
# once (302µs+65.5ms) by Catalyst::Utils::ensure_class_loaded at line 14 | ||||
| 10 | 1 | 826µs | 2 | 65.5ms | eval "use LaTeX::Driver"; # spent 65.5ms making 1 call to Epoll::View::Latex::BEGIN@2
# spent 18µs making 1 call to Class::Accessor::import |
| 11 | 1 | 16µs | if (!$@) { | ||
| 12 | 1 | 3µs | $__PACKAGE__::enable = 1; | ||
| 13 | } | ||||
| 14 | 1 | 863µs | 1 | 65.8ms | } # spent 65.8ms making 1 call to Epoll::View::Latex::BEGIN@9 |
| 15 | |||||
| 16 | 1 | 55µs | 2 | 7.01ms | __PACKAGE__->config( # spent 5.62ms making 1 call to Catalyst::Component::config
# spent 1.39ms making 1 call to Catalyst::path_to |
| 17 | TEMPLATE_EXTENSION => '.tt', | ||||
| 18 | INCLUDE_PATH => Epoll->path_to( 'root', 'latex' ), | ||||
| 19 | PRE_PROCESS => 'includes/header.tt', | ||||
| 20 | POST_PROCESS => 'includes/footer.tt', | ||||
| 21 | PLUGIN_BASE => 'Epoll::Template::Plugin', | ||||
| 22 | POST_CHOMP => 1, | ||||
| 23 | PRE_CHOMP => 1, | ||||
| 24 | ); | ||||
| 25 | |||||
| 26 | =head1 NAME | ||||
| 27 | |||||
| 28 | Epoll::View::Latex - Latex View for Epoll | ||||
| 29 | |||||
| 30 | =head1 DESCRIPTION | ||||
| 31 | |||||
| 32 | TT View for Epoll. | ||||
| 33 | |||||
| 34 | =cut | ||||
| 35 | |||||
| 36 | sub enabled { | ||||
| 37 | $__PACKAGE__::enable; | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | sub process { | ||||
| 41 | my ($self, $c) = @_; | ||||
| 42 | |||||
| 43 | $c->stash->{format} ||= 'pdf'; | ||||
| 44 | my $output = $self->render( | ||||
| 45 | $c, $c->stash->{template} | ||||
| 46 | ); | ||||
| 47 | |||||
| 48 | if ($c->stash->{format} eq 'tex') { | ||||
| 49 | $c->res->body($output); | ||||
| 50 | return; | ||||
| 51 | } | ||||
| 52 | |||||
| 53 | my ($fh, $filename) = File::Temp::tempfile( | ||||
| 54 | SUFFIX => ('.' . $c->stash->{format}), | ||||
| 55 | ); | ||||
| 56 | close($fh); | ||||
| 57 | |||||
| 58 | LaTeX::Driver::hack->new( | ||||
| 59 | source => \$output, | ||||
| 60 | output => $filename, | ||||
| 61 | format => $c->stash->{format}, | ||||
| 62 | )->run; | ||||
| 63 | open($fh, '<', $filename); | ||||
| 64 | unlink($filename); | ||||
| 65 | binmode($fh); | ||||
| 66 | $c->res->body(join('', <$fh>)); | ||||
| 67 | close($fh); | ||||
| 68 | } | ||||
| 69 | |||||
| 70 | # This is just a hack | ||||
| 71 | # Don't ask me why, but system() return -1 instead 0 | ||||
| 72 | # under catalyst... | ||||
| 73 | # This is just an ugly workaround | ||||
| 74 | |||||
| 75 | package LaTeX::Driver::hack; | ||||
| 76 | 3 | 1.05ms | 2 | 579µs | # spent 309µs (40+269) within LaTeX::Driver::hack::BEGIN@76 which was called
# once (40µs+269µs) by Catalyst::Utils::ensure_class_loaded at line 76 # spent 309µs making 1 call to LaTeX::Driver::hack::BEGIN@76
# spent 270µs making 1 call to base::import |
| 77 | |||||
| 78 | sub run_command { | ||||
| 79 | my ($self, @args) = @_; | ||||
| 80 | for (0 .. 2) { | ||||
| 81 | my $res = $self->SUPER::run_command(@args); | ||||
| 82 | if ($res > 0) { return $res } | ||||
| 83 | } | ||||
| 84 | 0; # is ok | ||||
| 85 | } | ||||
| 86 | |||||
| 87 | =head1 SEE ALSO | ||||
| 88 | |||||
| 89 | L<Epoll> | ||||
| 90 | |||||
| 91 | =head1 AUTHOR | ||||
| 92 | |||||
| 93 | Thauvin Olivier | ||||
| 94 | |||||
| 95 | =head1 LICENSE | ||||
| 96 | |||||
| 97 | This library is free software, you can redistribute it and/or modify | ||||
| 98 | it under the same terms as Perl itself or CeCILL. | ||||
| 99 | |||||
| 100 | =cut | ||||
| 101 | |||||
| 102 | 1 | 23µs | 1; |