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

Filename/var/www/foswikidev/core/lib/Foswiki/WebFilter.pm
StatementsExecuted 234 statements in 879µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2411463µs19.3msFoswiki::WebFilter::::okFoswiki::WebFilter::ok
21181µs81µsFoswiki::WebFilter::::newFoswiki::WebFilter::new
11115µs29µsFoswiki::WebFilter::::BEGIN@4Foswiki::WebFilter::BEGIN@4
11110µs14µsFoswiki::WebFilter::::BEGIN@5Foswiki::WebFilter::BEGIN@5
1114µs4µsFoswiki::WebFilter::::BEGIN@7Foswiki::WebFilter::BEGIN@7
0000s0sFoswiki::WebFilter::::publicFoswiki::WebFilter::public
0000s0sFoswiki::WebFilter::::userFoswiki::WebFilter::user
0000s0sFoswiki::WebFilter::::user_allowedFoswiki::WebFilter::user_allowed
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::WebFilter;
3
4228µs242µs
# spent 29µs (15+13) within Foswiki::WebFilter::BEGIN@4 which was called: # once (15µs+13µs) by Foswiki::Search::BEGIN@25 at line 4
use strict;
# spent 29µs making 1 call to Foswiki::WebFilter::BEGIN@4 # spent 13µs making 1 call to strict::import
5250µs218µs
# spent 14µs (10+4) within Foswiki::WebFilter::BEGIN@5 which was called: # once (10µs+4µs) by Foswiki::Search::BEGIN@25 at line 5
use warnings;
# spent 14µs making 1 call to Foswiki::WebFilter::BEGIN@5 # spent 4µs making 1 call to warnings::import
6
7
# spent 4µs within Foswiki::WebFilter::BEGIN@7 which was called: # once (4µs+0s) by Foswiki::Search::BEGIN@25 at line 12
BEGIN {
815µs if ( $Foswiki::cfg{UseLocale} ) {
9 require locale;
10 import locale();
11 }
121318µs14µs}
# spent 4µs making 1 call to Foswiki::WebFilter::BEGIN@7
13
14# PH made these lazy getters rather than globals in Item11349
151200nsmy $public;
161100nsmy $user;
1710smy $user_allowed;
18
19#TODO: documentme
20#TODO: should this be converted to a FilterIterator?
21
22# spec in the $filter,
23# which may include one of:
24# 1 'user' (for only user webs)
25# 2 'template' (for only template webs)
26# $filter may also contain the word 'public' which will further filter
27# webs on whether NOSEARCHALL is specified for them or not.
28# 'allowed' filters out webs that the user is denied access to by a *WEBVIEW.
29
30
# spent 81µs within Foswiki::WebFilter::new which was called 2 times, avg 40µs/call: # 2 times (81µs+0s) by Foswiki::Func::getListOfWebs at line 1542 of /var/www/foswikidev/core/lib/Foswiki/Func.pm, avg 40µs/call
sub new {
3123µs my ( $class, $filter ) = @_;
32216µs my $this = bless( {}, $class );
3323µs foreach my $f (qw(user template public allowed)) {
34855µs $this->{$f} = ( $filter =~ m/\b$f\b/ );
35 }
36210µs return $this;
37}
38
39
# spent 19.3ms (463µs+18.9) within Foswiki::WebFilter::ok which was called 24 times, avg 806µs/call: # 24 times (463µs+18.9ms) by Foswiki::deepWebList at line 1658 of /var/www/foswikidev/core/lib/Foswiki.pm, avg 806µs/call
sub ok {
402412µs my ( $this, $session, $web ) = @_;
41
42248µs return 0 if $this->{template} && $web !~ /(?:^_|\/_)/;
43
442414µs return 1 if ( $web eq $session->{webName} );
45
462264µs return 0 if $this->{user} && $web =~ m/(?:^_|\/_)/;
47
482048µs201.38ms return 0 if !$session->webExists($web);
# spent 1.38ms making 20 calls to Foswiki::webExists, avg 69µs/call
49
501953µs19210µs my $webObject = Foswiki::Meta->new( $session, $web );
# spent 210µs making 19 calls to Foswiki::Meta::new, avg 11µs/call
511950µs3816.8ms my $thisWebNoSearchAll =
# spent 16.6ms making 19 calls to Foswiki::Meta::getPreference, avg 876µs/call # spent 145µs making 19 calls to Foswiki::isTrue, avg 8µs/call
52 Foswiki::isTrue( $webObject->getPreference('NOSEARCHALL') );
53
541947µs1947µs return 0
# spent 47µs making 19 calls to Foswiki::Users::isAdmin, avg 2µs/call
55 if $this->{public}
56 && !$session->{users}->isAdmin( $session->{user} )
57 && $thisWebNoSearchAll;
58
591928µs19454µs return 0 if $this->{allowed} && !$webObject->haveAccess('VIEW');
# spent 454µs making 19 calls to Foswiki::Meta::haveAccess, avg 24µs/call
60
611964µs return 1;
62}
63
64sub public {
65 my ($class) = @_;
66
67 if ( !defined $public ) {
68 $public = $class->new('public');
69 }
70
71 return $public;
72}
73
74sub user {
75 my ($class) = @_;
76
77 if ( !defined $public ) {
78 $public = $class->new('user');
79 }
80
81 return $public;
82}
83
84sub user_allowed {
85 my ($class) = @_;
86
87 if ( !defined $public ) {
88 $public = $class->new('user,allowed');
89 }
90
91 return $public;
92}
93
9413µs1;
95__END__