← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:16 2015

Filename/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm
StatementsExecuted 209 statements in 1.03ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1133169µs379µsFoswiki::::USERINFOFoswiki::USERINFO
111152µs164µsFoswiki::::_USERINFO_tokenFoswiki::_USERINFO_token
71139µs57µsFoswiki::::__ANON__[:42]Foswiki::__ANON__[:42]
21117µs23µsFoswiki::::__ANON__[:26]Foswiki::__ANON__[:26]
11116µs29µsFoswiki::::BEGIN@4.103Foswiki::BEGIN@4.103
21113µs33µsFoswiki::::__ANON__[:51]Foswiki::__ANON__[:51]
11110µs14µsFoswiki::::BEGIN@5.104Foswiki::BEGIN@5.104
1114µs4µsFoswiki::::BEGIN@7.105Foswiki::BEGIN@7.105
0000s0sFoswiki::::__ANON__[:34]Foswiki::__ANON__[:34]
0000s0sFoswiki::::__ANON__[:57]Foswiki::__ANON__[:57]
0000s0sFoswiki::::__ANON__[:71]Foswiki::__ANON__[:71]
0000s0sFoswiki::::__ANON__[:79]Foswiki::__ANON__[:79]
0000s0sFoswiki::::__ANON__[:87]Foswiki::__ANON__[:87]
0000s0sFoswiki::::__ANON__[:92]Foswiki::__ANON__[:92]
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
4226µs241µs
# spent 29µs (16+12) within Foswiki::BEGIN@4.103 which was called: # once (16µs+12µs) by Foswiki::_expandMacroOnTopicRendering at line 4
use strict;
# spent 29µs making 1 call to Foswiki::BEGIN@4.103 # spent 12µs making 1 call to strict::import
5245µs218µs
# spent 14µs (10+4) within Foswiki::BEGIN@5.104 which was called: # once (10µs+4µs) by Foswiki::_expandMacroOnTopicRendering at line 5
use warnings;
# spent 14µs making 1 call to Foswiki::BEGIN@5.104 # spent 4µs making 1 call to warnings::import
6
7
# spent 4µs within Foswiki::BEGIN@7.105 which was called: # once (4µs+0s) by Foswiki::_expandMacroOnTopicRendering at line 12
BEGIN {
815µs if ( $Foswiki::cfg{UseLocale} ) {
9 require locale;
10 import locale();
11 }
121654µs14µs}
# spent 4µs making 1 call to Foswiki::BEGIN@7.105
13
14# Set to true if user details should be cloaked. Selected tokens will return an empty string.
151400nsmy $USERINFO_cloak = 0;
16
17my %USERINFO_tokens = (
18
# spent 23µs (17+7) within Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:26] which was called 2 times, avg 12µs/call: # 2 times (17µs+7µs) by Foswiki::_USERINFO_token at line 145, avg 12µs/call
username => sub {
1921µs my ( $this, $user ) = @_;
202500ns return '' if ($USERINFO_cloak);
21
2225µs26µs my $username = $this->{users}->getLoginName($user);
# spent 6µs making 2 calls to Foswiki::Users::getLoginName, avg 3µs/call
232200ns $username = 'unknown' unless defined $username;
24
2526µs return $username;
26 },
27
28 # Item2466: There is some usage of this undocumented token in VariableTests
29 cUID => sub {
30 my ( $this, $user ) = @_;
31
32 return '' if ($USERINFO_cloak);
33 return $user;
34 },
35
# spent 57µs (39+18) within Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:42] which was called 7 times, avg 8µs/call: # 7 times (39µs+18µs) by Foswiki::_USERINFO_token at line 145, avg 8µs/call
wikiname => sub {
3673µs my ( $this, $user ) = @_;
37711µs718µs my $wikiname = $this->{users}->getWikiName($user);
# spent 18µs making 7 calls to Foswiki::Users::getWikiName, avg 2µs/call
38
397800ns $wikiname = 'UnknownUser' unless defined $wikiname;
40
41716µs return $wikiname;
42 },
43
# spent 33µs (13+20) within Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:51] which was called 2 times, avg 16µs/call: # 2 times (13µs+20µs) by Foswiki::_USERINFO_token at line 145, avg 16µs/call
wikiusername => sub {
4421µs my ( $this, $user ) = @_;
4525µs220µs my $wikiusername = $this->{users}->webDotWikiName($user);
# spent 20µs making 2 calls to Foswiki::Users::webDotWikiName, avg 10µs/call
46
472300ns $wikiusername = "$Foswiki::cfg{UsersWebName}.UnknownUser"
48 unless defined $wikiusername;
49
5026µs return $wikiusername;
51 },
52 emails => sub {
53 my ( $this, $user ) = @_;
54
55 return '' if ($USERINFO_cloak);
56 return join( ', ', $this->{users}->getEmails($user) );
57 },
58 groups => sub {
59 my ( $this, $user ) = @_;
60 my @groupNames;
61 return '' if ($USERINFO_cloak);
62
63 my $it = $this->{users}->eachMembership($user);
64
65 while ( $it->hasNext() ) {
66 my $group = $it->next();
67 push( @groupNames, $group );
68 }
69
70 return join( ', ', @groupNames );
71 },
72
73 # Item2466: $admin was re-documented as $isadmin November 2011, do not remove
74 admin => sub {
75 my ( $this, $user ) = @_;
76
77 return '' if ($USERINFO_cloak);
78 return $this->{users}->isAdmin($user) ? 'true' : 'false';
79 },
80
81 # Item2466: $isadmin & $isgroup added November 2011
82 isadmin => sub {
83 my ( $this, $user ) = @_;
84
85 return '' if ($USERINFO_cloak);
86 return $this->{users}->isAdmin($user) ? 'true' : 'false';
87 },
88 isgroup => sub {
89 my ( $this, $user ) = @_;
90
91 return $this->{users}->isGroup($user) ? 'true' : 'false';
92 }
93121µs);
9414µsmy $USERINFO_tokenregex = join( '|', keys %USERINFO_tokens );
95
96
# spent 379µs (169+210) within Foswiki::USERINFO which was called 11 times, avg 34µs/call: # 7 times (88µs+113µs) by Foswiki::WIKINAME at line 22 of /var/www/foswikidev/core/lib/Foswiki/Macros/WIKINAME.pm, avg 29µs/call # 2 times (52µs+55µs) by Foswiki::WIKIUSERNAME at line 22 of /var/www/foswikidev/core/lib/Foswiki/Macros/WIKIUSERNAME.pm, avg 54µs/call # 2 times (29µs+42µs) by Foswiki::USERNAME at line 23 of /var/www/foswikidev/core/lib/Foswiki/Macros/USERNAME.pm, avg 35µs/call
sub USERINFO {
97114µs my ( $this, $params ) = @_;
98114µs my $format = $params->{format} || '$username, $wikiusername, $emails';
99114µs my $user = $this->{user};
100111µs my $info = $format;
101
102114µs if ( $params->{_DEFAULT} ) {
103 $user = $params->{_DEFAULT};
104 return '' if !$user;
105
106 # map wikiname to a login name
107 my $cuid = $this->{users}->getCanonicalUserID($user);
108 if ( !$cuid ) {
109
110 # Failed to get a cUID: if it's a group, leave $user alone
111 if ( !$this->{users}->isGroup($user) ) {
112 return '';
113 }
114 }
115 else {
116 $user = $cuid;
117 }
118 return '' unless $user;
119
120 $USERINFO_cloak =
121 ( $Foswiki::cfg{AntiSpam}{HideUserDetails}
122 && !$this->{users}->isAdmin( $this->{user} )
123 && $user ne $this->{user} );
124 }
125 else {
126113µs $USERINFO_cloak = 0;
127 }
128
129111µs return '' unless $user;
130
1312288µs11164µs $info =~ s/\$($USERINFO_tokenregex)/$this->_USERINFO_token($1, $user)/ge;
# spent 164µs making 11 calls to Foswiki::_USERINFO_token, avg 15µs/call
1321117µs1145µs $info = Foswiki::expandStandardEscapes($info);
# spent 45µs making 11 calls to Foswiki::expandStandardEscapes, avg 4µs/call
133
1341130µs return $info;
135}
136
137
# spent 164µs (52+113) within Foswiki::_USERINFO_token which was called 11 times, avg 15µs/call: # 11 times (52µs+113µs) by Foswiki::USERINFO at line 131, avg 15µs/call
sub _USERINFO_token {
1381112µs my ( $this, $token, $user ) = @_;
139
140 ASSERT($token) if DEBUG;
14111800ns ASSERT( ref( $USERINFO_tokens{$token} ) eq 'CODE',
142 "No code for token '$token'" )
143 if DEBUG;
144
1451140µs11113µs return $USERINFO_tokens{$token}->( $this, $user );
# spent 57µs making 7 calls to Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:42], avg 8µs/call # spent 33µs making 2 calls to Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:51], avg 16µs/call # spent 23µs making 2 calls to Foswiki::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Macros/USERINFO.pm:26], avg 12µs/call
146}
147
14815µs1;
149__END__