Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm |
Statements | Executed 195 statements in 2.30ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
9 | 3 | 3 | 542µs | 3.97ms | init (recurses: max depth 2, inclusive time 1.77ms) | Foswiki::Plugins::JQueryPlugin::Plugin::
5 | 5 | 5 | 301µs | 323µs | new | Foswiki::Plugins::JQueryPlugin::Plugin::
6 | 1 | 1 | 76µs | 76µs | renderJS | Foswiki::Plugins::JQueryPlugin::Plugin::
12 | 2 | 1 | 26µs | 26µs | CORE:match (opcode) | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 26µs | 26µs | BEGIN@4 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 25µs | 175µs | BEGIN@9 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 20µs | 38µs | BEGIN@8 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 16µs | 23µs | BEGIN@7 | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 16µs | 16µs | renderCSS | Foswiki::Plugins::JQueryPlugin::Plugin::
5 | 1 | 1 | 11µs | 11µs | CORE:subst (opcode) | Foswiki::Plugins::JQueryPlugin::Plugin::
1 | 1 | 1 | 9µs | 9µs | BEGIN@5 | Foswiki::Plugins::JQueryPlugin::Plugin::
0 | 0 | 0 | 0s | 0s | getSummary | Foswiki::Plugins::JQueryPlugin::Plugin::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Plugins::JQueryPlugin::Plugin; | ||||
3 | |||||
4 | 2 | 42µs | 1 | 26µs | # spent 26µs within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@4 which was called:
# once (26µs+0s) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 4 # spent 26µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@4 |
5 | 2 | 41µs | 1 | 9µs | # spent 9µs within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@5 which was called:
# once (9µs+0s) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 5 # spent 9µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@5 |
6 | |||||
7 | 2 | 47µs | 2 | 30µs | # spent 23µs (16+7) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@7 which was called:
# once (16µs+7µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 7 # spent 23µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@7
# spent 7µs making 1 call to strict::import |
8 | 2 | 47µs | 2 | 56µs | # spent 38µs (20+18) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@8 which was called:
# once (20µs+18µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 8 # spent 38µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@8
# spent 18µs making 1 call to warnings::import |
9 | 2 | 1.14ms | 2 | 325µs | # spent 175µs (25+150) within Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9 which was called:
# once (25µs+150µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::BEGIN@7 at line 9 # spent 175µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::BEGIN@9
# spent 150µs making 1 call to constant::import |
10 | |||||
11 | =begin TML | ||||
12 | |||||
13 | ---+ package Foswiki::Plugins::JQueryPlugin::Plugin | ||||
14 | |||||
15 | abstract 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 323µs (301+21) within Foswiki::Plugins::JQueryPlugin::Plugin::new which was called 5 times, avg 65µs/call:
# once (87µs+6µs) by Foswiki::Plugins::JQueryPlugin::TEXTBOXLIST::new at line 28 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/TEXTBOXLIST.pm
# once (66µs+4µs) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::new at line 29 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
# once (52µs+4µs) by Foswiki::Plugins::JQueryPlugin::METADATA::new at line 28 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/METADATA.pm
# once (48µs+4µs) by Foswiki::Plugins::JQueryPlugin::UI::new at line 29 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/UI.pm
# once (48µs+4µs) by Foswiki::Plugins::JQueryPlugin::LIVEQUERY::new at line 28 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/LIVEQUERY.pm | ||||
36 | 5 | 10µs | my $class = shift; | ||
37 | |||||
38 | # backwards compatibility: the session param is deprecated now | ||||
39 | 5 | 47µs | 5 | 10µs | if ( ref( $_[0] ) =~ /^Foswiki/ ) { # spent 10µs making 5 calls to Foswiki::Plugins::JQueryPlugin::Plugin::CORE:match, avg 2µs/call |
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 | |||||
49 | 5 | 138µ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 | |||||
68 | 5 | 24µs | $this->{documentation} = | ||
69 | $Foswiki::cfg{SystemWebName} . '.JQuery' . ucfirst( $this->{name} ) | ||||
70 | unless defined $this->{documentation}; | ||||
71 | |||||
72 | 5 | 46µs | 5 | 11µs | $this->{documentation} =~ s/:://g; # spent 11µs making 5 calls to Foswiki::Plugins::JQueryPlugin::Plugin::CORE:subst, avg 2µs/call |
73 | |||||
74 | 5 | 13µs | unless ( $this->{puburl} ) { | ||
75 | 4 | 17µs | $this->{puburl} = '%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/' | ||
76 | . lc( $this->{name} ); | ||||
77 | } | ||||
78 | |||||
79 | 5 | 42µs | return $this; | ||
80 | } | ||||
81 | |||||
82 | =begin TML | ||||
83 | |||||
84 | ---++ ClassMethod init( ) | ||||
85 | |||||
86 | add jQuery plugin to web and make sure all its dependencies | ||||
87 | are fulfilled. | ||||
88 | |||||
89 | =cut | ||||
90 | |||||
91 | # spent 3.97ms (542µs+3.43) within Foswiki::Plugins::JQueryPlugin::Plugin::init which was called 9 times, avg 441µs/call:
# 7 times (339µs+2.49ms) by Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin at line 84 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm, avg 403µs/call
# once (100µs+1.04ms) by Foswiki::Plugins::JQueryPlugin::FOSWIKI::init at line 56 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
# once (103µs+-103µs) by Foswiki::Plugins::JQueryPlugin::UI::init at line 56 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/JQueryPlugin/UI.pm | ||||
92 | 9 | 14µs | my $this = shift; | ||
93 | |||||
94 | 9 | 32µs | return 0 if $this->{isInit}; | ||
95 | 5 | 9µs | $this->{isInit} = 1; | ||
96 | |||||
97 | 5 | 9µs | my $header = ''; | ||
98 | 5 | 7µs | my $footer = ''; | ||
99 | |||||
100 | # load all css | ||||
101 | 10 | 32µs | foreach my $css ( @{ $this->{css} } ) { | ||
102 | 1 | 16µs | 1 | 16µs | $header .= $this->renderCSS($css); # spent 16µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugin::renderCSS |
103 | } | ||||
104 | |||||
105 | # load all javascript | ||||
106 | 10 | 29µs | foreach my $js ( @{ $this->{javascript} } ) { | ||
107 | 6 | 70µs | 6 | 76µs | $footer .= $this->renderJS($js); # spent 76µs making 6 calls to Foswiki::Plugins::JQueryPlugin::Plugin::renderJS, avg 13µs/call |
108 | } | ||||
109 | |||||
110 | # gather dependencies | ||||
111 | 5 | 13µs | my @dependencies = | ||
112 | ('JQUERYPLUGIN::FOSWIKI'); # jquery.foswiki is in there by default | ||||
113 | 10 | 53µs | foreach my $dep ( @{ $this->{dependencies} } ) { | ||
114 | 7 | 72µs | 7 | 16µs | if ( $dep =~ /^(JQUERYPLUGIN|JavascriptFiles)/ ) # spent 16µs making 7 calls to Foswiki::Plugins::JQueryPlugin::Plugin::CORE:match, avg 2µs/call |
115 | { # SMELL: there are some jquery modules that depend on non-jquery code | ||||
116 | 1 | 2µs | push @dependencies, $dep; | ||
117 | } | ||||
118 | else { | ||||
119 | 6 | 36µs | 6 | 0s | Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin($dep); # spent 4.31ms making 6 calls to Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin, avg 719µs/call, recursion: max depth 2, sum of overlapping time 4.31ms |
120 | 6 | 17µs | push @dependencies, 'JQUERYPLUGIN::' . uc($dep); | ||
121 | } | ||||
122 | } | ||||
123 | |||||
124 | Foswiki::Func::addToZone( | ||||
125 | 5 | 46µs | 5 | 427µs | 'head', "JQUERYPLUGIN::" . uc( $this->{name} ), # spent 427µs making 5 calls to Foswiki::Func::addToZone, avg 85µs/call |
126 | $header, join( ', ', @dependencies ) | ||||
127 | ); | ||||
128 | 5 | 40µs | 5 | 346µs | Foswiki::Func::addToZone( # spent 346µs making 5 calls to Foswiki::Func::addToZone, avg 69µs/call |
129 | 'script', "JQUERYPLUGIN::" . uc( $this->{name} ), | ||||
130 | $footer, join( ', ', @dependencies ) | ||||
131 | ); | ||||
132 | |||||
133 | 5 | 33µs | return 1; | ||
134 | } | ||||
135 | |||||
136 | # spent 16µs within Foswiki::Plugins::JQueryPlugin::Plugin::renderCSS which was called:
# once (16µs+0s) by Foswiki::Plugins::JQueryPlugin::Plugin::init at line 102 | ||||
137 | 1 | 3µs | my ( $this, $text ) = @_; | ||
138 | |||||
139 | 1 | 2µs | $text =~ s/\.css$/.uncompressed.css/ if $this->{debug}; | ||
140 | 1 | 3µs | $text .= '?version=' . $this->{version}; | ||
141 | 1 | 3µs | $text = | ||
142 | "<link rel='stylesheet' href='$this->{puburl}/$text' type='text/css' media='all' />\n"; | ||||
143 | |||||
144 | 1 | 11µs | return $text; | ||
145 | } | ||||
146 | |||||
147 | # spent 76µs within Foswiki::Plugins::JQueryPlugin::Plugin::renderJS which was called 6 times, avg 13µs/call:
# 6 times (76µs+0s) by Foswiki::Plugins::JQueryPlugin::Plugin::init at line 107, avg 13µs/call | ||||
148 | 6 | 12µs | my ( $this, $text ) = @_; | ||
149 | |||||
150 | 6 | 10µs | $text =~ s/\.js$/.uncompressed.js/ if $this->{debug}; | ||
151 | 6 | 12µs | $text .= '?version=' . $this->{version}; | ||
152 | 6 | 15µs | $text = | ||
153 | "<script type='text/javascript' src='$this->{puburl}/$text'></script>\n"; | ||||
154 | |||||
155 | 6 | 41µs | return $text; | ||
156 | } | ||||
157 | |||||
158 | =begin TML | ||||
159 | |||||
160 | ---++ ClassMethod getSummary() | ||||
161 | |||||
162 | returns the summary text for this plugin. this is either the =summary= property of the class or the | ||||
163 | =summary= section of the plugin's documentation topic. | ||||
164 | |||||
165 | =cut | ||||
166 | |||||
167 | sub getSummary { | ||||
168 | my $this = shift; | ||||
169 | |||||
170 | my $summary = $this->{summary}; | ||||
171 | |||||
172 | unless ( defined $summary ) { | ||||
173 | $summary = 'n/a'; | ||||
174 | if ( $this->{'documentation'} ) { | ||||
175 | $summary = | ||||
176 | Foswiki::Func::expandCommonVariables( '%INCLUDE{"' | ||||
177 | . $this->{documentation} | ||||
178 | . '" section="summary" warn="off"}%' ); | ||||
179 | } | ||||
180 | |||||
181 | $this->{summary} = $summary; | ||||
182 | } | ||||
183 | |||||
184 | return $summary; | ||||
185 | } | ||||
186 | |||||
187 | 1 | 4µs | 1; | ||
188 | __END__ | ||||
sub Foswiki::Plugins::JQueryPlugin::Plugin::CORE:match; # opcode | |||||
# spent 11µs within Foswiki::Plugins::JQueryPlugin::Plugin::CORE:subst which was called 5 times, avg 2µs/call:
# 5 times (11µs+0s) by Foswiki::Plugins::JQueryPlugin::Plugin::new at line 72, avg 2µs/call |