Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 41 lines (33 sloc) 1.164 kb
b9978c4 Adding this guide to profiling Bricolage (Mason) templates
Scott Lanning authored
1 package Bric::Profile::Templates;
2 use base qw(HTML::Mason::Plugin);
3
4 use Bric::Config qw(TEMPLATE_BURN_PKG);
5 use Bric::Util::Burner qw(:modes);
6 use Bric::Util::DBI qw(prepare_c execute);
7 use Time::HiRes;
8
9 sub start_component_hook {
10 my ($self, $context) = @_;
11 push @{ $self->{timers} }, Time::HiRes::time;
12 }
13
14 sub end_component_hook {
15 my ($self, $context) = @_;
16
17 my $end_time = Time::HiRes::time;
18 my $duration = $end_time - pop @{ $self->{timers} };
19
20 my ($burner, $element) = do {
21 no strict 'refs';
22 ${TEMPLATE_BURN_PKG . '::burner'}, ${TEMPLATE_BURN_PKG .
23 '::element'};
24 };
25 my $story_element_id = ref $element ? $element->get_id : 0;
26 my $comp_path = $context->comp->path;
27 my $output_channel_id = $burner->get_oc->get_id;
28 my $mode = $burner->get_mode;
29
30 my $sql = q{
31 INSERT INTO profile_comp
32 (end_time, duration, story_element_id, comp_path,
33 output_channel_id, mode)
34 VALUES (to_timestamp(?), ?, ?, ?, ?, ?)};
35 my $insert = prepare_c($sql);
36 execute($insert, $end_time, $duration, $story_element_id, $comp_path,
37 $output_channel_id, $mode);
38 }
39
40 1;
Something went wrong with that request. Please try again.