Filename | /var/www/foswiki11/lib/Foswiki/Engine/CLI.pm |
Statements | Executed 56 statements in 1.34ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 5.88ms | 5.89ms | preparePath | Foswiki::Engine::CLI::
1 | 1 | 1 | 2.65ms | 9.07ms | BEGIN@23 | Foswiki::Engine::CLI::
1 | 1 | 1 | 1.98ms | 2.05ms | BEGIN@25 | Foswiki::Engine::CLI::
1 | 1 | 1 | 1.78ms | 2.00ms | BEGIN@20 | Foswiki::Engine::CLI::
1 | 1 | 1 | 452µs | 533µs | BEGIN@24 | Foswiki::Engine::CLI::
1 | 1 | 1 | 80µs | 61.4s | run | Foswiki::Engine::CLI::
1 | 1 | 1 | 73µs | 73µs | write | Foswiki::Engine::CLI::
1 | 1 | 1 | 18µs | 35µs | BEGIN@16 | Foswiki::Engine::CLI::
1 | 1 | 1 | 17µs | 111µs | prepareQueryParameters | Foswiki::Engine::CLI::
1 | 1 | 1 | 15µs | 44µs | BEGIN@18 | Foswiki::Engine::CLI::
1 | 1 | 1 | 12µs | 18µs | prepareConnection | Foswiki::Engine::CLI::
1 | 1 | 1 | 11µs | 18µs | BEGIN@17 | Foswiki::Engine::CLI::
1 | 1 | 1 | 8µs | 11µs | prepareHeaders | Foswiki::Engine::CLI::
1 | 1 | 1 | 3µs | 3µs | finalizeHeaders | Foswiki::Engine::CLI::
1 | 1 | 1 | 1µs | 1µs | 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 | 35µs | 2 | 52µs | # spent 35µs (18+17) within Foswiki::Engine::CLI::BEGIN@16 which was called:
# once (18µs+17µs) by Foswiki::BEGIN@1 at line 16 # spent 35µs making 1 call to Foswiki::Engine::CLI::BEGIN@16
# spent 17µs making 1 call to strict::import |
17 | 2 | 28µs | 2 | 25µs | # spent 18µs (11+7) within Foswiki::Engine::CLI::BEGIN@17 which was called:
# once (11µs+7µs) by Foswiki::BEGIN@1 at line 17 # spent 18µs making 1 call to Foswiki::Engine::CLI::BEGIN@17
# spent 7µs making 1 call to warnings::import |
18 | 2 | 41µs | 2 | 73µs | # spent 44µs (15+29) within Foswiki::Engine::CLI::BEGIN@18 which was called:
# once (15µs+29µs) by Foswiki::BEGIN@1 at line 18 # spent 44µs making 1 call to Foswiki::Engine::CLI::BEGIN@18
# spent 29µs making 1 call to Assert::import |
19 | |||||
20 | 2 | 141µs | 1 | 2.00ms | # spent 2.00ms (1.78+225µs) within Foswiki::Engine::CLI::BEGIN@20 which was called:
# once (1.78ms+225µs) by Foswiki::BEGIN@1 at line 20 # spent 2.00ms making 1 call to Foswiki::Engine::CLI::BEGIN@20 |
21 | 1 | 9µs | our @ISA = ('Foswiki::Engine'); | ||
22 | |||||
23 | 2 | 127µs | 1 | 9.07ms | # spent 9.07ms (2.65+6.42) within Foswiki::Engine::CLI::BEGIN@23 which was called:
# once (2.65ms+6.42ms) by Foswiki::BEGIN@1 at line 23 # spent 9.07ms making 1 call to Foswiki::Engine::CLI::BEGIN@23 |
24 | 2 | 115µs | 1 | 533µs | # spent 533µs (452+81) within Foswiki::Engine::CLI::BEGIN@24 which was called:
# once (452µs+81µs) by Foswiki::BEGIN@1 at line 24 # spent 533µs making 1 call to Foswiki::Engine::CLI::BEGIN@24 |
25 | 2 | 638µs | 1 | 2.05ms | # spent 2.05ms (1.98+76µs) within Foswiki::Engine::CLI::BEGIN@25 which was called:
# once (1.98ms+76µs) by Foswiki::BEGIN@1 at line 25 # spent 2.05ms making 1 call to Foswiki::Engine::CLI::BEGIN@25 |
26 | |||||
27 | # spent 61.4s (80µs+61.4) within Foswiki::Engine::CLI::run which was called:
# once (80µs+61.4s) by main::RUNTIME at line 24 of view | ||||
28 | 1 | 900ns | my $this = shift; | ||
29 | 1 | 2µs | my @args = @ARGV; # Copy, so original @ARGV doesn't get modified | ||
30 | 1 | 1µs | while ( scalar @args ) { | ||
31 | 2 | 300ns | my $name; | ||
32 | 2 | 2µs | my $arg = shift @args; | ||
33 | 2 | 7µs | if ( $arg =~ /^-?([a-z0-9_]+)=(.*)$/i ) { | ||
34 | 2 | 7µs | 4 | 8µs | ( $name, $arg ) = ( TAINT($1), TAINT($2) ); # spent 8µs making 4 calls to Assert::noop, avg 2µs/call |
35 | } | ||||
36 | elsif ( $arg =~ /^-([a-z0-9_]+)/i ) { | ||||
37 | ( $name, $arg ) = ( TAINT($1), shift(@args) ); | ||||
38 | } | ||||
39 | 2 | 3µs | if ( $name && $name eq 'user' ) { | ||
40 | $this->{user} = $arg; | ||||
41 | } | ||||
42 | elsif ($name) { | ||||
43 | 2 | 4µs | push @{ $this->{plist} }, $name | ||
44 | unless exists $this->{params}->{$name}; | ||||
45 | 2 | 2µs | push @{ $this->{params}->{$name} }, $arg; | ||
46 | } | ||||
47 | else { | ||||
48 | $this->{path_info} = $arg; # keep it tainted | ||||
49 | } | ||||
50 | } | ||||
51 | 1 | 6µs | 1 | 6.19ms | my $req = $this->prepare; # spent 6.19ms making 1 call to Foswiki::Engine::prepare |
52 | 1 | 11µs | 1 | 2µs | if ( UNIVERSAL::isa( $req, 'Foswiki::Request' ) ) { # spent 2µs making 1 call to UNIVERSAL::isa |
53 | 1 | 2µs | 1 | 61.4s | my $res = Foswiki::UI::handleRequest($req); # spent 61.4s making 1 call to Foswiki::UI::handleRequest |
54 | 1 | 24µs | 1 | 258µs | $this->finalize( $res, $req ); # spent 258µs making 1 call to Foswiki::Engine::finalize |
55 | } | ||||
56 | } | ||||
57 | |||||
58 | # spent 18µs (12+7) within Foswiki::Engine::CLI::prepareConnection which was called:
# once (12µs+7µs) by Foswiki::Engine::__ANON__[/var/www/foswiki11/lib/Foswiki/Engine.pm:77] at line 69 of /var/www/foswiki11/lib/Foswiki/Engine.pm | ||||
59 | 1 | 1µs | my ( $this, $req ) = @_; | ||
60 | 1 | 2µs | 1 | 4µs | $req->remoteAddress('127.0.0.1'); # spent 4µs making 1 call to Foswiki::Request::remoteAddress |
61 | 1 | 7µs | 1 | 3µs | $req->method( $ENV{FOSWIKI_ACTION} ); # spent 3µs making 1 call to Foswiki::Request::method |
62 | } | ||||
63 | |||||
64 | # spent 111µs (17+95) within Foswiki::Engine::CLI::prepareQueryParameters which was called:
# once (17µs+95µs) by Foswiki::Engine::__ANON__[/var/www/foswiki11/lib/Foswiki/Engine.pm:77] at line 70 of /var/www/foswiki11/lib/Foswiki/Engine.pm | ||||
65 | 1 | 800ns | my ( $this, $req ) = @_; | ||
66 | 1 | 2µs | foreach my $name ( @{ $this->{plist} } ) { | ||
67 | 2 | 8µs | 2 | 95µs | $req->param( -name => $name, -value => $this->{params}->{$name} ); # spent 95µs making 2 calls to Foswiki::Request::param, avg 47µs/call |
68 | } | ||||
69 | 1 | 1µs | delete $this->{plist}; | ||
70 | 1 | 4µs | delete $this->{params}; | ||
71 | } | ||||
72 | |||||
73 | # spent 11µs (8+3) within Foswiki::Engine::CLI::prepareHeaders which was called:
# once (8µs+3µs) by Foswiki::Engine::__ANON__[/var/www/foswiki11/lib/Foswiki/Engine.pm:77] at line 71 of /var/www/foswiki11/lib/Foswiki/Engine.pm | ||||
74 | 1 | 800ns | my ( $this, $req ) = @_; | ||
75 | 1 | 7µs | if ( defined $this->{user} ) { | ||
76 | $req->remoteUser( $this->{user} ); | ||||
77 | delete $this->{user}; | ||||
78 | } | ||||
79 | else { | ||||
80 | 1 | 3µs | 1 | 3µs | $req->remoteUser( $Foswiki::cfg{AdminUserWikiName} ); # spent 3µs making 1 call to Foswiki::Request::remoteUser |
81 | } | ||||
82 | } | ||||
83 | |||||
84 | # spent 5.89ms (5.88+7µs) within Foswiki::Engine::CLI::preparePath which was called:
# once (5.88ms+7µs) by Foswiki::Engine::__ANON__[/var/www/foswiki11/lib/Foswiki/Engine.pm:77] at line 73 of /var/www/foswiki11/lib/Foswiki/Engine.pm | ||||
85 | 1 | 1µs | my ( $this, $req ) = @_; | ||
86 | 1 | 2µs | 1 | 7µs | if ( $ENV{FOSWIKI_ACTION} ) { # spent 7µs making 1 call to Foswiki::Request::action |
87 | $req->action( $ENV{FOSWIKI_ACTION} ); | ||||
88 | } | ||||
89 | else { | ||||
90 | require File::Spec; | ||||
91 | $req->action( ( File::Spec->splitpath($0) )[2] ); | ||||
92 | } | ||||
93 | 1 | 7µs | if ( exists $this->{path_info} ) { | ||
94 | $req->pathInfo( $this->{path_info} ); | ||||
95 | delete $this->{path_info}; | ||||
96 | } | ||||
97 | } | ||||
98 | |||||
99 | 1 | 3µs | # spent 1µs within Foswiki::Engine::CLI::prepareCookies which was called:
# once (1µs+0s) by Foswiki::Engine::__ANON__[/var/www/foswiki11/lib/Foswiki/Engine.pm:77] at line 72 of /var/www/foswiki11/lib/Foswiki/Engine.pm | ||
100 | |||||
101 | 1 | 4µs | # spent 3µs within Foswiki::Engine::CLI::finalizeHeaders which was called:
# once (3µs+0s) by Foswiki::Engine::finalize at line 278 of /var/www/foswiki11/lib/Foswiki/Engine.pm | ||
102 | |||||
103 | # spent 73µs within Foswiki::Engine::CLI::write which was called:
# once (73µs+0s) by Foswiki::Engine::finalizeBody at line 391 of /var/www/foswiki11/lib/Foswiki/Engine.pm | ||||
104 | 1 | 5µs | my ( $this, $buffer ) = @_; | ||
105 | 1 | 73µs | print $buffer; | ||
106 | } | ||||
107 | |||||
108 | 1 | 4µs | 1; | ||
109 | __END__ |