← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:35 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/USERINFO.pm
StatementsExecuted 153 statements in 2.29ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
833429µs1.88msFoswiki::::USERINFOFoswiki::USERINFO
811251µs722µsFoswiki::::_USERINFO_tokenFoswiki::_USERINFO_token
41193µs296µsFoswiki::::__ANON__[:40]Foswiki::__ANON__[:40]
31151µs79µsFoswiki::::__ANON__[:31]Foswiki::__ANON__[:31]
11129µs36µsFoswiki::::BEGIN@4.35Foswiki::BEGIN@4.35
11126µs105µsFoswiki::::BEGIN@6Foswiki::BEGIN@6
11122µs36µsFoswiki::::__ANON__[:16]Foswiki::__ANON__[:16]
11120µs37µsFoswiki::::BEGIN@5.36Foswiki::BEGIN@5.36
0000s0sFoswiki::::__ANON__[:23]Foswiki::__ANON__[:23]
0000s0sFoswiki::::__ANON__[:45]Foswiki::__ANON__[:45]
0000s0sFoswiki::::__ANON__[:57]Foswiki::__ANON__[:57]
0000s0sFoswiki::::__ANON__[:64]Foswiki::__ANON__[:64]
0000s0sFoswiki::::__ANON__[:71]Foswiki::__ANON__[:71]
0000s0sFoswiki::::__ANON__[:76]Foswiki::__ANON__[:76]
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;
3
4254µs243µs
# spent 36µs (29+7) within Foswiki::BEGIN@4.35 which was called: # once (29µs+7µs) by Foswiki::_expandMacroOnTopicRendering at line 4
use strict;
# spent 36µs making 1 call to Foswiki::BEGIN@4.35 # spent 7µs making 1 call to strict::import
5252µs255µs
# spent 37µs (20+18) within Foswiki::BEGIN@5.36 which was called: # once (20µs+18µs) by Foswiki::_expandMacroOnTopicRendering at line 5
use warnings;
# spent 37µs making 1 call to Foswiki::BEGIN@5.36 # spent 18µs making 1 call to warnings::import
621.16ms2184µs
# spent 105µs (26+79) within Foswiki::BEGIN@6 which was called: # once (26µs+79µs) by Foswiki::_expandMacroOnTopicRendering at line 6
use Assert;
# spent 105µs making 1 call to Foswiki::BEGIN@6 # spent 79µs making 1 call to Assert::import
7
8my %USERINFO_tokens = (
9
# spent 36µs (22+14) within Foswiki::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/USERINFO.pm:16] which was called: # once (22µs+14µs) by Foswiki::_USERINFO_token at line 125
username => sub {
10427µs my ( $this, $user ) = @_;
11114µs my $username = $this->{users}->getLoginName($user);
# spent 14µs making 1 call to Foswiki::Users::getLoginName
12
13 $username = 'unknown' unless defined $username;
14
15 return $username;
16 },
17
18 # Item2466: There is some usage of this undocumented token in VariableTests
19 cUID => sub {
20 my ( $this, $user ) = @_;
21
22 return $user;
23 },
24
# spent 79µs (51+28) within Foswiki::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/USERINFO.pm:31] which was called 3 times, avg 26µs/call: # 3 times (51µs+28µs) by Foswiki::_USERINFO_token at line 125, avg 26µs/call
wikiname => sub {
251247µs my ( $this, $user ) = @_;
26328µs my $wikiname = $this->{users}->getWikiName($user);
# spent 28µs making 3 calls to Foswiki::Users::getWikiName, avg 9µs/call
27
28 $wikiname = 'UnknownUser' unless defined $wikiname;
29
30 return $wikiname;
31 },
32
# spent 296µs (93+203) within Foswiki::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/USERINFO.pm:40] which was called 4 times, avg 74µs/call: # 4 times (93µs+203µs) by Foswiki::_USERINFO_token at line 125, avg 74µs/call
wikiusername => sub {
3316103µs my ( $this, $user ) = @_;
344202µs my $wikiusername = $this->{users}->webDotWikiName($user);
# spent 202µs making 4 calls to Foswiki::Users::webDotWikiName, avg 51µs/call
35
36 $wikiusername = "$Foswiki::cfg{UsersWebName}.UnknownUser"
37 unless defined $wikiusername;
38
39 return $wikiusername;
40 },
41 emails => sub {
42 my ( $this, $user ) = @_;
43
44 return join( ', ', $this->{users}->getEmails($user) );
45 },
46 groups => sub {
47 my ( $this, $user ) = @_;
48 my @groupNames;
49 my $it = $this->{users}->eachMembership($user);
50
51 while ( $it->hasNext() ) {
52 my $group = $it->next();
53 push( @groupNames, $group );
54 }
55
56 return join( ', ', @groupNames );
57 },
58
59 # Item2466: $admin was re-documented as $isadmin November 2011, do not remove
60 admin => sub {
61 my ( $this, $user ) = @_;
62
63 return $this->{users}->isAdmin($user) ? 'true' : 'false';
64 },
65
66 # Item2466: $isadmin & $isgroup added November 2011
67 isadmin => sub {
68 my ( $this, $user ) = @_;
69
70 return $this->{users}->isAdmin($user) ? 'true' : 'false';
71 },
72 isgroup => sub {
73 my ( $this, $user ) = @_;
74
75 return $this->{users}->isGroup($user) ? 'true' : 'false';
76 }
77138µs);
7816µsmy $USERINFO_tokenregex = join( '|', keys %USERINFO_tokens );
79
80
# spent 1.88ms (429µs+1.45) within Foswiki::USERINFO which was called 8 times, avg 235µs/call: # 4 times (247µs+899µs) by Foswiki::WIKIUSERNAME at line 15 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/WIKIUSERNAME.pm, avg 286µs/call # 3 times (120µs+391µs) by Foswiki::WIKINAME at line 15 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/WIKINAME.pm, avg 170µs/call # once (63µs+163µs) by Foswiki::USERNAME at line 16 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/USERNAME.pm
sub USERINFO {
8180599µs my ( $this, $params ) = @_;
82 my $format = $params->{format} || '$username, $wikiusername, $emails';
83 my $user = $this->{user};
84 my $info = $format;
85
86 if ( $params->{_DEFAULT} ) {
87 $user = $params->{_DEFAULT};
88 return '' if !$user;
89
90 # map wikiname to a login name
91 my $cuid = $this->{users}->getCanonicalUserID($user);
92 if ( !$cuid ) {
93
94 # Failed to get a cUID: if it's a group, leave $user alone
95 if ( !$this->{users}->isGroup($user) ) {
96 return '';
97 }
98 }
99 else {
100 $user = $cuid;
101 }
102 return '' unless $user;
103 return ''
104 if ( $Foswiki::cfg{AntiSpam}{HideUserDetails}
105 && !$this->{users}->isAdmin( $this->{user} )
106 && $user ne $this->{user} );
107 }
108
109 return '' unless $user;
110
11140896µs $info =~ s/\$($USERINFO_tokenregex)/$this->_USERINFO_token($1, $user)/ge;
# spent 722µs making 8 calls to Foswiki::_USERINFO_token, avg 90µs/call # spent 81µs making 8 calls to Foswiki::CORE:regcomp, avg 10µs/call # spent 50µs making 8 calls to Foswiki::CORE:subst, avg 6µs/call # spent 43µs making 16 calls to Foswiki::CORE:substcont, avg 3µs/call
1128556µs $info = Foswiki::expandStandardEscapes($info);
# spent 556µs making 8 calls to Foswiki::expandStandardEscapes, avg 70µs/call
113
114 return $info;
115}
116
117
# spent 722µs (251+471) within Foswiki::_USERINFO_token which was called 8 times, avg 90µs/call: # 8 times (251µs+471µs) by Foswiki::USERINFO at line 111, avg 90µs/call
sub _USERINFO_token {
11832195µs my ( $this, $token, $user ) = @_;
119
120832µs ASSERT($token) if DEBUG;
# spent 32µs making 8 calls to Assert::ASSERTS_OFF, avg 4µs/call
121828µs ASSERT( ref( $USERINFO_tokens{$token} ) eq 'CODE',
# spent 28µs making 8 calls to Assert::ASSERTS_OFF, avg 3µs/call
122 "No code for token '$token'" )
123 if DEBUG;
124
1258411µs return $USERINFO_tokens{$token}->( $this, $user );
126}
127
128111µs1;
129__END__