Filename | /var/www/foswikidev/core/lib/Foswiki/Plugins/SpreadSheetPlugin.pm |
Statements | Executed 338 statements in 813µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
108 | 1 | 1 | 370µs | 370µs | commonTagsHandler | Foswiki::Plugins::SpreadSheetPlugin::
1 | 1 | 1 | 34µs | 154µs | initPlugin | Foswiki::Plugins::SpreadSheetPlugin::
1 | 1 | 1 | 13µs | 26µs | BEGIN@7 | Foswiki::Plugins::SpreadSheetPlugin::
1 | 1 | 1 | 10µs | 14µs | BEGIN@8 | Foswiki::Plugins::SpreadSheetPlugin::
1 | 1 | 1 | 9µs | 60µs | BEGIN@11 | Foswiki::Plugins::SpreadSheetPlugin::
0 | 0 | 0 | 0s | 0s | __ANON__[:50] | Foswiki::Plugins::SpreadSheetPlugin::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | # | ||||
3 | # This is Foswiki's Spreadsheet Plugin. | ||||
4 | |||||
5 | package Foswiki::Plugins::SpreadSheetPlugin; | ||||
6 | |||||
7 | 2 | 31µs | 2 | 40µs | # spent 26µs (13+13) within Foswiki::Plugins::SpreadSheetPlugin::BEGIN@7 which was called:
# once (13µs+13µs) by Foswiki::Plugin::BEGIN@2 at line 7 # spent 26µs making 1 call to Foswiki::Plugins::SpreadSheetPlugin::BEGIN@7
# spent 13µs making 1 call to strict::import |
8 | 2 | 35µs | 2 | 18µs | # spent 14µs (10+4) within Foswiki::Plugins::SpreadSheetPlugin::BEGIN@8 which was called:
# once (10µs+4µs) by Foswiki::Plugin::BEGIN@2 at line 8 # spent 14µs making 1 call to Foswiki::Plugins::SpreadSheetPlugin::BEGIN@8
# spent 4µs making 1 call to warnings::import |
9 | |||||
10 | # ========================= | ||||
11 | 1 | 5µs | 1 | 51µs | # spent 60µs (9+51) within Foswiki::Plugins::SpreadSheetPlugin::BEGIN@11 which was called:
# once (9µs+51µs) by Foswiki::Plugin::BEGIN@2 at line 13 # spent 51µs making 1 call to vars::import |
12 | $web $topic $user $installWeb $debug $skipInclude $doInit | ||||
13 | 1 | 369µs | 1 | 60µs | ); # spent 60µs making 1 call to Foswiki::Plugins::SpreadSheetPlugin::BEGIN@11 |
14 | |||||
15 | 1 | 700ns | our $VERSION = '1.20'; | ||
16 | 1 | 200ns | our $RELEASE = '1.20'; | ||
17 | 1 | 200ns | our $NO_PREFS_IN_TOPIC = 1; | ||
18 | 1 | 200ns | our $SHORTDESCRIPTION = | ||
19 | 'Add spreadsheet calculations like "$SUM($ABOVE())" to Foswiki tables and other topic text'; | ||||
20 | |||||
21 | 1 | 100ns | $doInit = 0; | ||
22 | |||||
23 | # ========================= | ||||
24 | # spent 154µs (34+121) within Foswiki::Plugins::SpreadSheetPlugin::initPlugin which was called:
# once (34µs+121µs) by Foswiki::Plugin::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Plugin.pm:257] at line 250 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm | ||||
25 | 1 | 2µs | ( $topic, $web, $user, $installWeb ) = @_; | ||
26 | |||||
27 | # check for Plugins.pm versions | ||||
28 | 1 | 20µs | 1 | 12µs | if ( $Foswiki::Plugins::VERSION < 1 ) { # spent 12µs making 1 call to version::vxs::VCMP |
29 | Foswiki::Func::writeWarning( | ||||
30 | "Version mismatch between SpreadSheetPlugin and Plugins.pm"); | ||||
31 | return 0; | ||||
32 | } | ||||
33 | |||||
34 | # Get plugin debug flag | ||||
35 | 1 | 3µs | 1 | 40µs | $debug = Foswiki::Func::getPreferencesFlag("SPREADSHEETPLUGIN_DEBUG") || 0; # spent 40µs making 1 call to Foswiki::Func::getPreferencesFlag |
36 | |||||
37 | # Following code is for a registered tag handler that does the same as | ||||
38 | # CALC but in a tag handler instead of in commonTagsHandler. That means | ||||
39 | # you can't use table references, but you can rely on the execution order | ||||
40 | # relative to other macros. | ||||
41 | Foswiki::Func::registerTagHandler( | ||||
42 | "CALCULATE", | ||||
43 | sub { | ||||
44 | my ( $session, $attributes, $topic, $web ) = @_; | ||||
45 | require Foswiki::Plugins::SpreadSheetPlugin::Calc; | ||||
46 | $Foswiki::Plugins::SpreadSheetPlugin::Calc::rPos = 0; | ||||
47 | $Foswiki::Plugins::SpreadSheetPlugin::Calc::cPos = 0; | ||||
48 | return Foswiki::Plugins::SpreadSheetPlugin::Calc::_doCalc( | ||||
49 | $attributes->{_DEFAULT} ); | ||||
50 | } | ||||
51 | 1 | 6µs | 1 | 23µs | ); # spent 23µs making 1 call to Foswiki::Func::registerTagHandler |
52 | |||||
53 | # Flag to skip calc if in include | ||||
54 | 1 | 2µs | 1 | 27µs | $skipInclude = # spent 27µs making 1 call to Foswiki::Func::getPreferencesFlag |
55 | Foswiki::Func::getPreferencesFlag("SPREADSHEETPLUGIN_SKIPINCLUDE"); | ||||
56 | 1 | 2µs | 1 | 18µs | my $skipIncludePref = # spent 18µs making 1 call to Foswiki::Func::getPreferencesValue |
57 | Foswiki::Func::getPreferencesValue("SPREADSHEETPLUGIN_SKIPINCLUDE"); | ||||
58 | 1 | 700ns | $skipInclude = 1 unless defined $skipIncludePref && $skipIncludePref ne ''; | ||
59 | |||||
60 | # Plugin correctly initialized | ||||
61 | 1 | 600ns | Foswiki::Func::writeDebug( | ||
62 | "- Foswiki::Plugins::SpreadSheetPlugin::initPlugin( $web.$topic ) is OK" | ||||
63 | ) if $debug; | ||||
64 | 1 | 400ns | $doInit = 1; | ||
65 | 1 | 4µs | return 1; | ||
66 | } | ||||
67 | |||||
68 | # ========================= | ||||
69 | # spent 370µs within Foswiki::Plugins::SpreadSheetPlugin::commonTagsHandler which was called 108 times, avg 3µs/call:
# 108 times (370µs+0s) by Foswiki::Plugin::invoke at line 310 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm, avg 3µs/call | ||||
70 | ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead | ||||
71 | |||||
72 | 108 | 16µs | Foswiki::Func::writeDebug( | ||
73 | "- SpreadSheetPlugin::commonTagsHandler( $_[2].$_[1] )") | ||||
74 | if $debug; | ||||
75 | |||||
76 | 108 | 38µs | if ( ( $_[3] ) && ($skipInclude) ) { | ||
77 | |||||
78 | # bail out, handler called from an %INCLUDE{}% | ||||
79 | return; | ||||
80 | } | ||||
81 | 100 | 273µs | unless ( $_[0] =~ m/%CALC\{.*?\}%/ ) { | ||
82 | |||||
83 | # nothing to do | ||||
84 | return; | ||||
85 | } | ||||
86 | |||||
87 | require Foswiki::Plugins::SpreadSheetPlugin::Calc; | ||||
88 | |||||
89 | if ($doInit) { | ||||
90 | $doInit = 0; | ||||
91 | Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web, $topic, $debug ); | ||||
92 | } | ||||
93 | Foswiki::Plugins::SpreadSheetPlugin::Calc::CALC(@_); | ||||
94 | } | ||||
95 | |||||
96 | 1 | 4µs | 1; | ||
97 | |||||
98 | __END__ |