← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:10 2015

Filename/var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm
StatementsExecuted 66 statements in 1.18ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
22267µs688µsFoswiki::Plugins::JQueryPlugin::Plugin::::initFoswiki::Plugins::JQueryPlugin::Plugin::init (recurses: max depth 1, inclusive time 86µs)
22253µs53µsFoswiki::Plugins::JQueryPlugin::Plugin::::newFoswiki::Plugins::JQueryPlugin::Plugin::new
11118µs86µsFoswiki::Plugins::JQueryPlugin::Plugin::::BEGIN@9Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9
11114µs29µsFoswiki::Plugins::JQueryPlugin::Plugin::::BEGIN@7Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@7
11112µs12µsFoswiki::Plugins::JQueryPlugin::Plugin::::BEGIN@4Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@4
11111µs18µsFoswiki::Plugins::JQueryPlugin::Plugin::::BEGIN@8Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@8
21111µs11µsFoswiki::Plugins::JQueryPlugin::Plugin::::renderJSFoswiki::Plugins::JQueryPlugin::Plugin::renderJS
1114µs4µsFoswiki::Plugins::JQueryPlugin::Plugin::::BEGIN@5Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@5
0000s0sFoswiki::Plugins::JQueryPlugin::Plugin::::getSummaryFoswiki::Plugins::JQueryPlugin::Plugin::getSummary
0000s0sFoswiki::Plugins::JQueryPlugin::Plugin::::renderCSSFoswiki::Plugins::JQueryPlugin::Plugin::renderCSS
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2package Foswiki::Plugins::JQueryPlugin::Plugin;
3
4231µs112µs
# spent 12µs within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@4 which was called: # once (12µs+0s) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 4
use Foswiki::Plugins::JQueryPlugin::Plugins ();
# spent 12µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@4
5235µs14µs
# spent 4µs within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@5 which was called: # once (4µs+0s) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 5
use Foswiki::Func ();
# spent 4µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@5
6
7231µs245µs
# spent 29µs (14+16) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@7 which was called: # once (14µs+16µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 7
use strict;
# spent 29µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@7 # spent 16µs making 1 call to strict::import
8232µs224µs
# spent 18µs (11+6) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@8 which was called: # once (11µs+6µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 8
use warnings;
# spent 18µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@8 # spent 6µs making 1 call to warnings::import
92907µs2153µs
# spent 86µs (18+67) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9 which was called: # once (18µs+67µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 9
use constant DEBUG => 0;
# spent 86µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9 # spent 67µs making 1 call to constant::import
10
11=begin TML
12
13---+ package Foswiki::Plugins::JQueryPlugin::Plugin
14
15abstract class for a jQuery plugin
16
17=cut
18
19=begin TML
20
21---++ ClassMethod new( $class, ... )
22
23 * =$class=: Plugin class
24 * =...=: additional properties to be added to the object. i.e.
25 * =name => 'pluginName'= (default unknown)
26 * =author => 'pluginAuthor'= (default unknown)
27 * =version => 'pluginVersion'= (default unknown)
28 * =summary => 'pluginSummary'= (default undefined)
29 * =documentation => 'pluginDocumentation'= (default JQuery<Name>)
30 * =homepage => 'pluginHomepage'= (default unknown)
31 * =debug => 0 or 1= (default =$Foswiki::cfg{JQueryPlugin}{Debug}=)
32
33=cut
34
35
# spent 53µs within Foswiki::Plugins::JQueryPlugin::Plugin::new which was called 2 times, avg 26µs/call: # once (29µs+0s) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::new at line 29 of /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm # once (24µs+0s) by Foswiki::Plugins::JQueryPlugin::LIVEQUERY::new at line 28 of /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/LIVEQUERY.pm
sub new {
3621µs my $class = shift;
37
38 # backwards compatibility: the session param is deprecated now
3921µs if ( ref( $_[0] ) =~ /^Foswiki/ ) {
40 my ( $package, $file, $line ) = caller;
41
42 # emit a deprecation warning
43 print STDERR
44"$package constructor called with deprecated session object in $file:$line\n"
45 if DEBUG;
46 shift; # ... it off the args
47 }
48
49235µs my $this = bless(
50 {
51 debug => $Foswiki::cfg{JQueryPlugin}{Debug} || 0,
52 name => $class,
53 author => 'unknown',
54 version => 'unknown',
55 summary => undef,
56 documentation => undef,
57 homepage => 'unknown',
58 puburl => '',
59 css => [],
60 javascript => [],
61 dependencies => [],
62 tags => '',
63 @_
64 },
65 $class
66 );
67
6825µs $this->{documentation} =
69 $Foswiki::cfg{SystemWebName} . '.JQuery' . ucfirst( $this->{name} )
70 unless defined $this->{documentation};
71
7222µs $this->{documentation} =~ s/:://g;
73
7423µs unless ( $this->{puburl} ) {
75 $this->{puburl} = '%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/'
76 . lc( $this->{name} );
77 }
78
79213µs return $this;
80}
81
82=begin TML
83
84---++ ClassMethod init( )
85
86add jQuery plugin to web and make sure all its dependencies
87are fulfilled.
88
89=cut
90
91
# spent 688µs (67+621) within Foswiki::Plugins::JQueryPlugin::Plugin::init which was called 2 times, avg 344µs/call: # once (38µs+650µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::init at line 57 of /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm # once (30µs+-30µs) by Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin at line 115 of /var/www/foswiki11/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm
sub init {
922700ns my $this = shift;
93
9421µs return 0 if $this->{isInit};
9521µs $this->{isInit} = 1;
96
972800ns my $header = '';
982500ns my $footer = '';
99
100 # load all css
10123µs foreach my $css ( @{ $this->{css} } ) {
102 $header .= $this->renderCSS($css);
103 }
104
105 # load all javascript
10621µs foreach my $js ( @{ $this->{javascript} } ) {
107210µs211µs $footer .= $this->renderJS($js);
# spent 11µs making 2 calls to Foswiki::Plugins::JQueryPlugin::Plugin::renderJS, avg 6µs/call
108 }
109
110 # gather dependencies
11122µs my @dependencies =
112 ('JQUERYPLUGIN::FOSWIKI'); # jquery.foswiki is in there by default
11322µs foreach my $dep ( @{ $this->{dependencies} } ) {
11437µs if ( $dep =~ /^(JQUERYPLUGIN|JavascriptFiles)/ )
115 { # SMELL: there are some jquery modules that depend on non-jquery code
116 push @dependencies, $dep;
117 }
118 else {
11914µs10s Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin($dep);
# spent 577µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin, recursion: max depth 1, sum of overlapping time 577µs
12012µs push @dependencies, 'JQUERYPLUGIN::' . uc($dep);
121 }
122 }
123
124 Foswiki::Func::addToZone(
12527µs267µs 'head', "JQUERYPLUGIN::" . uc( $this->{name} ),
# spent 67µs making 2 calls to Foswiki::Func::addToZone, avg 33µs/call
126 $header, join( ', ', @dependencies )
127 );
12826µs252µs Foswiki::Func::addToZone(
# spent 52µs making 2 calls to Foswiki::Func::addToZone, avg 26µs/call
129 'script', "JQUERYPLUGIN::" . uc( $this->{name} ),
130 $footer, join( ', ', @dependencies )
131 );
132
133210µs return 1;
134}
135
136sub renderCSS {
137 my ( $this, $text ) = @_;
138
139 $text =~ s/\.css$/.uncompressed.css/
140 if $this->{debug} && $text !~ /(\.uncompressed|_src)\./;
141 $text .= '?version=' . $this->{version};
142 $text =
143"<link rel='stylesheet' href='$this->{puburl}/$text' type='text/css' media='all' />\n";
144
145 return $text;
146}
147
148
# spent 11µs within Foswiki::Plugins::JQueryPlugin::Plugin::renderJS which was called 2 times, avg 6µs/call: # 2 times (11µs+0s) by Foswiki::Plugins::JQueryPlugin::Plugin::init at line 107, avg 6µs/call
sub renderJS {
14922µs my ( $this, $text ) = @_;
150
1512800ns $text =~ s/\.js$/.uncompressed.js/
152 if $this->{debug} && $text !~ /(\.uncompressed|_src)\./;
15322µs $text .= '?version=' . $this->{version};
15423µs $text =
155 "<script type='text/javascript' src='$this->{puburl}/$text'></script>\n";
156
15729µs return $text;
158}
159
160=begin TML
161
162---++ ClassMethod getSummary()
163
164returns the summary text for this plugin. this is either the =summary= property of the class or the
165=summary= section of the plugin's documentation topic.
166
167=cut
168
169sub getSummary {
170 my $this = shift;
171
172 my $summary = $this->{summary};
173
174 unless ( defined $summary ) {
175 $summary = 'n/a';
176 if ( $this->{'documentation'} ) {
177 $summary =
178 Foswiki::Func::expandCommonVariables( '%INCLUDE{"'
179 . $this->{documentation}
180 . '" section="summary" warn="off"}%' );
181 }
182
183 $this->{summary} = $summary;
184 }
185
186 return $summary;
187}
188
18913µs1;
190__END__