Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/USERINFO.pm |
Statements | Executed 153 statements in 2.29ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
8 | 3 | 3 | 429µs | 1.88ms | USERINFO | Foswiki::
8 | 1 | 1 | 251µs | 722µs | _USERINFO_token | Foswiki::
4 | 1 | 1 | 93µs | 296µs | __ANON__[:40] | Foswiki::
3 | 1 | 1 | 51µs | 79µs | __ANON__[:31] | Foswiki::
1 | 1 | 1 | 29µs | 36µs | BEGIN@4.35 | Foswiki::
1 | 1 | 1 | 26µs | 105µs | BEGIN@6 | Foswiki::
1 | 1 | 1 | 22µs | 36µs | __ANON__[:16] | Foswiki::
1 | 1 | 1 | 20µs | 37µs | BEGIN@5.36 | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:23] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:45] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:57] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:64] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:71] | Foswiki::
0 | 0 | 0 | 0s | 0s | __ANON__[:76] | Foswiki::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki; | ||||
3 | |||||
4 | 2 | 54µs | 2 | 43µ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 # spent 36µs making 1 call to Foswiki::BEGIN@4.35
# spent 7µs making 1 call to strict::import |
5 | 2 | 52µs | 2 | 55µ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 # spent 37µs making 1 call to Foswiki::BEGIN@5.36
# spent 18µs making 1 call to warnings::import |
6 | 2 | 1.16ms | 2 | 184µs | # spent 105µs (26+79) within Foswiki::BEGIN@6 which was called:
# once (26µs+79µs) by Foswiki::_expandMacroOnTopicRendering at line 6 # spent 105µs making 1 call to Foswiki::BEGIN@6
# spent 79µs making 1 call to Assert::import |
7 | |||||
8 | my %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 | ||||
10 | 1 | 3µs | my ( $this, $user ) = @_; | ||
11 | 1 | 12µs | 1 | 14µs | my $username = $this->{users}->getLoginName($user); # spent 14µs making 1 call to Foswiki::Users::getLoginName |
12 | |||||
13 | 1 | 1µs | $username = 'unknown' unless defined $username; | ||
14 | |||||
15 | 1 | 12µs | 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 | ||||
25 | 3 | 6µs | my ( $this, $user ) = @_; | ||
26 | 3 | 19µs | 3 | 28µs | my $wikiname = $this->{users}->getWikiName($user); # spent 28µs making 3 calls to Foswiki::Users::getWikiName, avg 9µs/call |
27 | |||||
28 | 3 | 4µs | $wikiname = 'UnknownUser' unless defined $wikiname; | ||
29 | |||||
30 | 3 | 18µs | 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 | ||||
33 | 4 | 10µs | my ( $this, $user ) = @_; | ||
34 | 4 | 55µs | 4 | 202µs | my $wikiusername = $this->{users}->webDotWikiName($user); # spent 202µs making 4 calls to Foswiki::Users::webDotWikiName, avg 51µs/call |
35 | |||||
36 | 4 | 6µs | $wikiusername = "$Foswiki::cfg{UsersWebName}.UnknownUser" | ||
37 | unless defined $wikiusername; | ||||
38 | |||||
39 | 4 | 32µs | 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 | } | ||||
77 | 1 | 38µs | ); | ||
78 | 1 | 6µs | my $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 | ||||
81 | 8 | 16µs | my ( $this, $params ) = @_; | ||
82 | 8 | 15µs | my $format = $params->{format} || '$username, $wikiusername, $emails'; | ||
83 | 8 | 19µs | my $user = $this->{user}; | ||
84 | 8 | 19µs | my $info = $format; | ||
85 | |||||
86 | 8 | 13µs | 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 | 8 | 11µs | return '' unless $user; | ||
110 | |||||
111 | 16 | 388µs | 40 | 896µ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 |
112 | 8 | 65µs | 8 | 556µs | $info = Foswiki::expandStandardEscapes($info); # spent 556µs making 8 calls to Foswiki::expandStandardEscapes, avg 70µs/call |
113 | |||||
114 | 8 | 53µs | 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 | ||||
118 | 8 | 28µs | my ( $this, $token, $user ) = @_; | ||
119 | |||||
120 | 8 | 41µs | 8 | 32µs | ASSERT($token) if DEBUG; # spent 32µs making 8 calls to Assert::ASSERTS_OFF, avg 4µs/call |
121 | 8 | 38µs | 8 | 28µ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 | |||||
125 | 8 | 89µs | 8 | 411µs | return $USERINFO_tokens{$token}->( $this, $user ); # spent 296µs making 4 calls to Foswiki::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/USERINFO.pm:40], avg 74µs/call
# spent 79µs making 3 calls to Foswiki::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/USERINFO.pm:31], avg 26µs/call
# spent 36µs making 1 call to Foswiki::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Macros/USERINFO.pm:16] |
126 | } | ||||
127 | |||||
128 | 1 | 11µs | 1; | ||
129 | __END__ |