Filename | /var/www/foswikidev/core/lib/Foswiki/Engine/CLI.pm |
Statements | Executed 57 statements in 1.19ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 2.39ms | 10.6ms | BEGIN@23 | Foswiki::Engine::CLI::
1 | 1 | 1 | 1.69ms | 1.77ms | BEGIN@25 | Foswiki::Engine::CLI::
1 | 1 | 1 | 1.55ms | 1.78ms | BEGIN@20 | Foswiki::Engine::CLI::
1 | 1 | 1 | 388µs | 469µs | BEGIN@24 | Foswiki::Engine::CLI::
1 | 1 | 1 | 87µs | 138s | run | Foswiki::Engine::CLI::
1 | 1 | 1 | 77µs | 77µs | write | Foswiki::Engine::CLI::
1 | 1 | 1 | 16µs | 108µs | prepareQueryParameters | Foswiki::Engine::CLI::
1 | 1 | 1 | 15µs | 23µs | BEGIN@17 | Foswiki::Engine::CLI::
1 | 1 | 1 | 14µs | 28µs | BEGIN@16 | Foswiki::Engine::CLI::
1 | 1 | 1 | 12µs | 41µs | BEGIN@18 | Foswiki::Engine::CLI::
1 | 1 | 1 | 10µs | 16µs | prepareConnection | Foswiki::Engine::CLI::
1 | 1 | 1 | 8µs | 11µs | prepareHeaders | Foswiki::Engine::CLI::
1 | 1 | 1 | 7µs | 15µs | preparePath | Foswiki::Engine::CLI::
1 | 1 | 1 | 4µs | 4µs | BEGIN@27 | Foswiki::Engine::CLI::
1 | 1 | 1 | 2µs | 2µs | finalizeHeaders | Foswiki::Engine::CLI::
1 | 1 | 1 | 900ns | 900ns | prepareCookies | Foswiki::Engine::CLI::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | =begin TML | ||||
4 | |||||
5 | ---+!! package Foswiki::Engine::CLI | ||||
6 | |||||
7 | Class that implements CGI scripts functionality when called from | ||||
8 | command line or cron job | ||||
9 | |||||
10 | Refer to Foswiki::Engine documentation for explanation about methos below. | ||||
11 | |||||
12 | =cut | ||||
13 | |||||
14 | package Foswiki::Engine::CLI; | ||||
15 | |||||
16 | 2 | 29µs | 2 | 42µs | # spent 28µs (14+14) within Foswiki::Engine::CLI::BEGIN@16 which was called:
# once (14µs+14µs) by Foswiki::BEGIN@1 at line 16 # spent 28µs making 1 call to Foswiki::Engine::CLI::BEGIN@16
# spent 14µs making 1 call to strict::import |
17 | 2 | 28µs | 2 | 31µs | # spent 23µs (15+8) within Foswiki::Engine::CLI::BEGIN@17 which was called:
# once (15µs+8µs) by Foswiki::BEGIN@1 at line 17 # spent 23µs making 1 call to Foswiki::Engine::CLI::BEGIN@17
# spent 8µs making 1 call to warnings::import |
18 | 2 | 29µs | 2 | 71µs | # spent 41µs (12+29) within Foswiki::Engine::CLI::BEGIN@18 which was called:
# once (12µs+29µs) by Foswiki::BEGIN@1 at line 18 # spent 41µs making 1 call to Foswiki::Engine::CLI::BEGIN@18
# spent 29µs making 1 call to Exporter::import |
19 | |||||
20 | 2 | 112µs | 1 | 1.78ms | # spent 1.78ms (1.55+229µs) within Foswiki::Engine::CLI::BEGIN@20 which was called:
# once (1.55ms+229µs) by Foswiki::BEGIN@1 at line 20 # spent 1.78ms making 1 call to Foswiki::Engine::CLI::BEGIN@20 |
21 | 1 | 8µs | our @ISA = ('Foswiki::Engine'); | ||
22 | |||||
23 | 2 | 102µs | 1 | 10.6ms | # spent 10.6ms (2.39+8.21) within Foswiki::Engine::CLI::BEGIN@23 which was called:
# once (2.39ms+8.21ms) by Foswiki::BEGIN@1 at line 23 # spent 10.6ms making 1 call to Foswiki::Engine::CLI::BEGIN@23 |
24 | 2 | 93µs | 1 | 469µs | # spent 469µs (388+81) within Foswiki::Engine::CLI::BEGIN@24 which was called:
# once (388µs+81µs) by Foswiki::BEGIN@1 at line 24 # spent 469µs making 1 call to Foswiki::Engine::CLI::BEGIN@24 |
25 | 2 | 113µs | 1 | 1.77ms | # spent 1.77ms (1.69+77µs) within Foswiki::Engine::CLI::BEGIN@25 which was called:
# once (1.69ms+77µs) by Foswiki::BEGIN@1 at line 25 # spent 1.77ms making 1 call to Foswiki::Engine::CLI::BEGIN@25 |
26 | |||||
27 | # spent 4µs within Foswiki::Engine::CLI::BEGIN@27 which was called:
# once (4µs+0s) by Foswiki::BEGIN@1 at line 32 | ||||
28 | 1 | 5µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
29 | require locale; | ||||
30 | import locale(); | ||||
31 | } | ||||
32 | 1 | 458µs | 1 | 4µs | } # spent 4µs making 1 call to Foswiki::Engine::CLI::BEGIN@27 |
33 | |||||
34 | # spent 138s (87µs+138) within Foswiki::Engine::CLI::run which was called:
# once (87µs+138s) by main::RUNTIME at line 29 of view | ||||
35 | 1 | 1µs | my $this = shift; | ||
36 | 1 | 2µs | my @args = @ARGV; # Copy, so original @ARGV doesn't get modified | ||
37 | 1 | 1µs | while ( scalar(@args) ) { | ||
38 | 2 | 600ns | my $name; | ||
39 | 2 | 1µs | my $arg = shift @args; | ||
40 | 2 | 8µs | if ( $arg =~ m/^-?([a-z0-9_]+)=(.*)$/i ) { | ||
41 | 2 | 7µs | 4 | 8µs | ( $name, $arg ) = ( TAINT($1), TAINT($2) ); # spent 8µs making 4 calls to Assert::TAINT, avg 2µs/call |
42 | } | ||||
43 | elsif ( $arg =~ m/^-([a-z0-9_]+)/i ) { | ||||
44 | ( $name, $arg ) = ( TAINT($1), shift(@args) ); | ||||
45 | } | ||||
46 | 2 | 3µs | if ( $name && $name eq 'user' ) { | ||
47 | $this->{user} = $arg; | ||||
48 | } | ||||
49 | elsif ($name) { | ||||
50 | 2 | 4µs | push @{ $this->{plist} }, $name | ||
51 | unless exists $this->{params}->{$name}; | ||||
52 | 2 | 2µs | push @{ $this->{params}->{$name} }, $arg; | ||
53 | } | ||||
54 | else { | ||||
55 | $this->{path_info} = $arg; # keep it tainted | ||||
56 | } | ||||
57 | } | ||||
58 | 1 | 6µs | 1 | 315µs | my $req = $this->prepare; # spent 315µs making 1 call to Foswiki::Engine::prepare |
59 | 1 | 11µs | 1 | 2µs | if ( UNIVERSAL::isa( $req, 'Foswiki::Request' ) ) { # spent 2µs making 1 call to UNIVERSAL::isa |
60 | 1 | 2µs | 1 | 138s | my $res = Foswiki::UI::handleRequest($req); # spent 138s making 1 call to Foswiki::UI::handleRequest |
61 | 1 | 28µs | 1 | 1.22ms | $this->finalize( $res, $req ); # spent 1.22ms making 1 call to Foswiki::Engine::finalize |
62 | } | ||||
63 | } | ||||
64 | |||||
65 | # spent 16µs (10+6) within Foswiki::Engine::CLI::prepareConnection which was called:
# once (10µs+6µs) by Foswiki::Engine::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Engine.pm:110] at line 102 of /var/www/foswikidev/core/lib/Foswiki/Engine.pm | ||||
66 | 1 | 1µs | my ( $this, $req ) = @_; | ||
67 | 1 | 2µs | 1 | 4µs | $req->remoteAddress('127.0.0.1'); # spent 4µs making 1 call to Foswiki::Request::remoteAddress |
68 | 1 | 6µs | 1 | 2µs | $req->method( $ENV{FOSWIKI_ACTION} ); # spent 2µs making 1 call to Foswiki::Request::method |
69 | } | ||||
70 | |||||
71 | # spent 108µs (16+92) within Foswiki::Engine::CLI::prepareQueryParameters which was called:
# once (16µs+92µs) by Foswiki::Engine::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Engine.pm:110] at line 103 of /var/www/foswikidev/core/lib/Foswiki/Engine.pm | ||||
72 | 1 | 1µs | my ( $this, $req ) = @_; | ||
73 | 1 | 1µs | foreach my $name ( @{ $this->{plist} } ) { | ||
74 | 2 | 7µs | 2 | 92µs | $req->param( -name => $name, -value => $this->{params}->{$name} ); # spent 92µs making 2 calls to Foswiki::Request::param, avg 46µs/call |
75 | } | ||||
76 | 1 | 2µs | delete $this->{plist}; | ||
77 | 1 | 5µs | delete $this->{params}; | ||
78 | } | ||||
79 | |||||
80 | # spent 11µs (8+3) within Foswiki::Engine::CLI::prepareHeaders which was called:
# once (8µs+3µs) by Foswiki::Engine::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Engine.pm:110] at line 104 of /var/www/foswikidev/core/lib/Foswiki/Engine.pm | ||||
81 | 1 | 800ns | my ( $this, $req ) = @_; | ||
82 | 1 | 4µs | if ( defined $this->{user} ) { | ||
83 | $req->remoteUser( $this->{user} ); | ||||
84 | delete $this->{user}; | ||||
85 | } | ||||
86 | else { | ||||
87 | 1 | 3µs | 1 | 3µs | if ( $Foswiki::cfg{Register}{AllowLoginName} ) { # spent 3µs making 1 call to Foswiki::Request::remoteUser |
88 | $req->remoteUser( $Foswiki::cfg{AdminUserLogin} ); | ||||
89 | } | ||||
90 | else { | ||||
91 | $req->remoteUser( $Foswiki::cfg{AdminUserWikiName} ); | ||||
92 | } | ||||
93 | } | ||||
94 | } | ||||
95 | |||||
96 | # spent 15µs (7+7) within Foswiki::Engine::CLI::preparePath which was called:
# once (7µs+7µs) by Foswiki::Engine::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Engine.pm:110] at line 106 of /var/www/foswikidev/core/lib/Foswiki/Engine.pm | ||||
97 | 1 | 1µs | my ( $this, $req ) = @_; | ||
98 | 1 | 3µs | 1 | 7µs | if ( $ENV{FOSWIKI_ACTION} ) { # spent 7µs making 1 call to Foswiki::Request::action |
99 | $req->action( $ENV{FOSWIKI_ACTION} ); | ||||
100 | } | ||||
101 | else { | ||||
102 | require File::Spec; | ||||
103 | $req->action( ( File::Spec->splitpath($0) )[2] ); | ||||
104 | } | ||||
105 | 1 | 3µs | if ( exists $this->{path_info} ) { | ||
106 | $req->pathInfo( $this->{path_info} ); | ||||
107 | delete $this->{path_info}; | ||||
108 | } | ||||
109 | } | ||||
110 | |||||
111 | 1 | 3µs | # spent 900ns within Foswiki::Engine::CLI::prepareCookies which was called:
# once (900ns+0s) by Foswiki::Engine::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Engine.pm:110] at line 105 of /var/www/foswikidev/core/lib/Foswiki/Engine.pm | ||
112 | |||||
113 | 1 | 4µs | # spent 2µs within Foswiki::Engine::CLI::finalizeHeaders which was called:
# once (2µs+0s) by Foswiki::Engine::finalize at line 318 of /var/www/foswikidev/core/lib/Foswiki/Engine.pm | ||
114 | |||||
115 | # spent 77µs within Foswiki::Engine::CLI::write which was called:
# once (77µs+0s) by Foswiki::Engine::finalizeBody at line 431 of /var/www/foswikidev/core/lib/Foswiki/Engine.pm | ||||
116 | 1 | 9µs | my ( $this, $buffer ) = @_; | ||
117 | 1 | 73µs | print $buffer; | ||
118 | } | ||||
119 | |||||
120 | 1 | 3µs | 1; | ||
121 | __END__ |