← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:11 2015

Filename/var/www/foswiki11/lib/Foswiki/Macros/USERINFO.pm
StatementsExecuted 183 statements in 1.97ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
933258µs669µsFoswiki::::USERINFOFoswiki::USERINFO
911141µs335µsFoswiki::::_USERINFO_tokenFoswiki::_USERINFO_token
51151µs70µsFoswiki::::__ANON__[:36]Foswiki::__ANON__[:36]
11135µs60µsFoswiki::::BEGIN@4.68Foswiki::BEGIN@4.68
21125µs63µsFoswiki::::__ANON__[:45]Foswiki::__ANON__[:45]
11124µs63µsFoswiki::::BEGIN@6Foswiki::BEGIN@6
21124µs36µsFoswiki::::__ANON__[:20]Foswiki::__ANON__[:20]
11120µs29µsFoswiki::::BEGIN@5.69Foswiki::BEGIN@5.69
0000s0sFoswiki::::__ANON__[:28]Foswiki::__ANON__[:28]
0000s0sFoswiki::::__ANON__[:51]Foswiki::__ANON__[:51]
0000s0sFoswiki::::__ANON__[:65]Foswiki::__ANON__[:65]
0000s0sFoswiki::::__ANON__[:73]Foswiki::__ANON__[:73]
0000s0sFoswiki::::__ANON__[:81]Foswiki::__ANON__[:81]
0000s0sFoswiki::::__ANON__[:86]Foswiki::__ANON__[:86]
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
4253µs284µs
# spent 60µs (35+25) within Foswiki::BEGIN@4.68 which was called: # once (35µs+25µs) by Foswiki::_expandMacroOnTopicRendering at line 4
use strict;
# spent 60µs making 1 call to Foswiki::BEGIN@4.68 # spent 25µs making 1 call to strict::import
5247µs238µs
# spent 29µs (20+9) within Foswiki::BEGIN@5.69 which was called: # once (20µs+9µs) by Foswiki::_expandMacroOnTopicRendering at line 5
use warnings;
# spent 29µs making 1 call to Foswiki::BEGIN@5.69 # spent 9µs making 1 call to warnings::import
621.36ms2103µs
# spent 63µs (24+39) within Foswiki::BEGIN@6 which was called: # once (24µs+39µs) by Foswiki::_expandMacroOnTopicRendering at line 6
use Assert;
# spent 63µs making 1 call to Foswiki::BEGIN@6 # spent 39µs making 1 call to Assert::import
7
8# Set to true if user details should be cloaked. Selected tokens will return an empty string.
91900nsmy $USERINFO_cloak = 0;
10
11my %USERINFO_tokens = (
12
# spent 36µs (24+13) within Foswiki::__ANON__[/var/www/foswiki11/lib/Foswiki/Macros/USERINFO.pm:20] which was called 2 times, avg 18µs/call: # 2 times (24µs+13µs) by Foswiki::_USERINFO_token at line 139, avg 18µs/call
username => sub {
1322µs my ( $this, $user ) = @_;
142500ns return '' if ($USERINFO_cloak);
15
1629µs213µs my $username = $this->{users}->getLoginName($user);
# spent 13µs making 2 calls to Foswiki::Users::getLoginName, avg 6µs/call
172700ns $username = 'unknown' unless defined $username;
18
19210µs return $username;
20 },
21
22 # Item2466: There is some usage of this undocumented token in VariableTests
23 cUID => sub {
24 my ( $this, $user ) = @_;
25
26 return '' if ($USERINFO_cloak);
27 return $user;
28 },
29
# spent 70µs (51+19) within Foswiki::__ANON__[/var/www/foswiki11/lib/Foswiki/Macros/USERINFO.pm:36] which was called 5 times, avg 14µs/call: # 5 times (51µs+19µs) by Foswiki::_USERINFO_token at line 139, avg 14µs/call
wikiname => sub {
3055µs my ( $this, $user ) = @_;
31515µs519µs my $wikiname = $this->{users}->getWikiName($user);
# spent 19µs making 5 calls to Foswiki::Users::getWikiName, avg 4µs/call
32
3351µs $wikiname = 'UnknownUser' unless defined $wikiname;
34
35521µs return $wikiname;
36 },
37
# spent 63µs (25+38) within Foswiki::__ANON__[/var/www/foswiki11/lib/Foswiki/Macros/USERINFO.pm:45] which was called 2 times, avg 32µs/call: # 2 times (25µs+38µs) by Foswiki::_USERINFO_token at line 139, avg 32µs/call
wikiusername => sub {
3822µs my ( $this, $user ) = @_;
39212µs238µs my $wikiusername = $this->{users}->webDotWikiName($user);
# spent 38µs making 2 calls to Foswiki::Users::webDotWikiName, avg 19µs/call
40
412500ns $wikiusername = "$Foswiki::cfg{UsersWebName}.UnknownUser"
42 unless defined $wikiusername;
43
44210µs return $wikiusername;
45 },
46 emails => sub {
47 my ( $this, $user ) = @_;
48
49 return '' if ($USERINFO_cloak);
50 return join( ', ', $this->{users}->getEmails($user) );
51 },
52 groups => sub {
53 my ( $this, $user ) = @_;
54 my @groupNames;
55 return '' if ($USERINFO_cloak);
56
57 my $it = $this->{users}->eachMembership($user);
58
59 while ( $it->hasNext() ) {
60 my $group = $it->next();
61 push( @groupNames, $group );
62 }
63
64 return join( ', ', @groupNames );
65 },
66
67 # Item2466: $admin was re-documented as $isadmin November 2011, do not remove
68 admin => sub {
69 my ( $this, $user ) = @_;
70
71 return '' if ($USERINFO_cloak);
72 return $this->{users}->isAdmin($user) ? 'true' : 'false';
73 },
74
75 # Item2466: $isadmin & $isgroup added November 2011
76 isadmin => sub {
77 my ( $this, $user ) = @_;
78
79 return '' if ($USERINFO_cloak);
80 return $this->{users}->isAdmin($user) ? 'true' : 'false';
81 },
82 isgroup => sub {
83 my ( $this, $user ) = @_;
84
85 return $this->{users}->isGroup($user) ? 'true' : 'false';
86 }
87153µs);
8817µsmy $USERINFO_tokenregex = join( '|', keys %USERINFO_tokens );
89
90
# spent 669µs (258+411) within Foswiki::USERINFO which was called 9 times, avg 74µs/call: # 5 times (100µs+186µs) by Foswiki::WIKINAME at line 15 of /var/www/foswiki11/lib/Foswiki/Macros/WIKINAME.pm, avg 57µs/call # 2 times (108µs+136µs) by Foswiki::WIKIUSERNAME at line 15 of /var/www/foswiki11/lib/Foswiki/Macros/WIKIUSERNAME.pm, avg 122µs/call # 2 times (51µs+88µs) by Foswiki::USERNAME at line 16 of /var/www/foswiki11/lib/Foswiki/Macros/USERNAME.pm, avg 70µs/call
sub USERINFO {
9196µs my ( $this, $params ) = @_;
9297µs my $format = $params->{format} || '$username, $wikiusername, $emails';
9397µs my $user = $this->{user};
9493µs my $info = $format;
95
9697µs if ( $params->{_DEFAULT} ) {
97 $user = $params->{_DEFAULT};
98 return '' if !$user;
99
100 # map wikiname to a login name
101 my $cuid = $this->{users}->getCanonicalUserID($user);
102 if ( !$cuid ) {
103
104 # Failed to get a cUID: if it's a group, leave $user alone
105 if ( !$this->{users}->isGroup($user) ) {
106 return '';
107 }
108 }
109 else {
110 $user = $cuid;
111 }
112 return '' unless $user;
113
114 $USERINFO_cloak =
115 ( $Foswiki::cfg{AntiSpam}{HideUserDetails}
116 && !$this->{users}->isAdmin( $this->{user} )
117 && $user ne $this->{user} );
118 }
119 else {
12095µs $USERINFO_cloak = 0;
121 }
122
12392µs return '' unless $user;
124
12518154µs9335µs $info =~ s/\$($USERINFO_tokenregex)/$this->_USERINFO_token($1, $user)/ge;
# spent 335µs making 9 calls to Foswiki::_USERINFO_token, avg 37µs/call
126927µs976µs $info = Foswiki::expandStandardEscapes($info);
# spent 76µs making 9 calls to Foswiki::expandStandardEscapes, avg 8µs/call
127
128942µs return $info;
129}
130
131
# spent 335µs (141+194) within Foswiki::_USERINFO_token which was called 9 times, avg 37µs/call: # 9 times (141µs+194µs) by Foswiki::USERINFO at line 125, avg 37µs/call
sub _USERINFO_token {
132915µs my ( $this, $token, $user ) = @_;
133
134914µs914µs ASSERT($token) if DEBUG;
# spent 14µs making 9 calls to Assert::ASSERTS_OFF, avg 2µs/call
135912µs99µs ASSERT( ref( $USERINFO_tokens{$token} ) eq 'CODE',
# spent 9µs making 9 calls to Assert::ASSERTS_OFF, avg 1µs/call
136 "No code for token '$token'" )
137 if DEBUG;
138
139950µs9170µs return $USERINFO_tokens{$token}->( $this, $user );
# spent 70µs making 5 calls to Foswiki::__ANON__[/var/www/foswiki11/lib/Foswiki/Macros/USERINFO.pm:36], avg 14µs/call # spent 63µs making 2 calls to Foswiki::__ANON__[/var/www/foswiki11/lib/Foswiki/Macros/USERINFO.pm:45], avg 32µs/call # spent 36µs making 2 calls to Foswiki::__ANON__[/var/www/foswiki11/lib/Foswiki/Macros/USERINFO.pm:20], avg 18µs/call
140}
141
142110µs1;
143__END__