← 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:50 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/WebFilter.pm
StatementsExecuted 32 statements in 892µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
331178µs303µsFoswiki::WebFilter::::newFoswiki::WebFilter::new
121190µs90µsFoswiki::WebFilter::::CORE:regcompFoswiki::WebFilter::CORE:regcomp (opcode)
11142µs63µsFoswiki::WebFilter::::BEGIN@5Foswiki::WebFilter::BEGIN@5
121135µs35µsFoswiki::WebFilter::::CORE:matchFoswiki::WebFilter::CORE:match (opcode)
11124µs32µsFoswiki::WebFilter::::BEGIN@4Foswiki::WebFilter::BEGIN@4
0000s0sFoswiki::WebFilter::::okFoswiki::WebFilter::ok
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
4246µs239µs
# spent 32µs (24+7) within Foswiki::WebFilter::BEGIN@4 which was called: # once (24µs+7µs) by Foswiki::Search::BEGIN@24 at line 4
use strict;
# spent 32µs making 1 call to Foswiki::WebFilter::BEGIN@4 # spent 7µs making 1 call to strict::import
52507µs283µs
# spent 63µs (42+20) within Foswiki::WebFilter::BEGIN@5 which was called: # once (42µs+20µs) by Foswiki::Search::BEGIN@24 at line 5
use warnings;
# spent 63µs making 1 call to Foswiki::WebFilter::BEGIN@5 # spent 20µs making 1 call to warnings::import
6
7#TODO: documentme
8#TODO: should this be converted to a FilterIterator?
9
10# spec in the $filter,
11# which may include one of:
12# 1 'user' (for only user webs)
13# 2 'template' (for only template webs)
14# $filter may also contain the word 'public' which will further filter
15# webs on whether NOSEARCHALL is specified for them or not.
16# 'allowed' filters out webs that the user is denied access to by a *WEBVIEW.
17
18
# spent 303µs (178+126) within Foswiki::WebFilter::new which was called 3 times, avg 101µs/call: # once (74µs+52µs) by Foswiki::Search::BEGIN@24 at line 52 # once (54µs+36µs) by Foswiki::Search::BEGIN@24 at line 53 # once (51µs+38µs) by Foswiki::Search::BEGIN@24 at line 54
sub new {
191255µs my ( $class, $filter ) = @_;
20 my $this = bless( {}, $class );
21 foreach my $f (qw(user template public allowed)) {
2212256µs24126µs $this->{$f} = ( $filter =~ /\b$f\b/ );
# spent 90µs making 12 calls to Foswiki::WebFilter::CORE:regcomp, avg 8µs/call # spent 35µs making 12 calls to Foswiki::WebFilter::CORE:match, avg 3µs/call
23 }
24 return $this;
25}
26
27sub ok {
28 my ( $this, $session, $web ) = @_;
29
30 return 0 if $this->{template} && $web !~ /(?:^_|\/_)/;
31
32 return 1 if ( $web eq $session->{webName} );
33
34 return 0 if $this->{user} && $web =~ /(?:^_|\/_)/;
35
36 return 0 if !$session->webExists($web);
37
38 my $webObject = Foswiki::Meta->new( $session, $web );
39 my $thisWebNoSearchAll =
40 Foswiki::isTrue( $webObject->getPreference('NOSEARCHALL') );
41
42 return 0
43 if $this->{public}
44 && !$session->{users}->isAdmin( $session->{user} )
45 && $thisWebNoSearchAll;
46
47 return 0 if $this->{allowed} && !$webObject->haveAccess('VIEW');
48
49 return 1;
50}
51
5218µs1126µsour $public = new Foswiki::WebFilter('public');
# spent 126µs making 1 call to Foswiki::WebFilter::new
5316µs189µsour $user = new Foswiki::WebFilter('user');
# spent 89µs making 1 call to Foswiki::WebFilter::new
5416µs189µsour $user_allowed = new Foswiki::WebFilter('user,allowed');
# spent 89µs making 1 call to Foswiki::WebFilter::new
55
5618µs1;
57__END__
 
# spent 35µs within Foswiki::WebFilter::CORE:match which was called 12 times, avg 3µs/call: # 12 times (35µs+0s) by Foswiki::WebFilter::new at line 22, avg 3µs/call
sub Foswiki::WebFilter::CORE:match; # opcode
# spent 90µs within Foswiki::WebFilter::CORE:regcomp which was called 12 times, avg 8µs/call: # 12 times (90µs+0s) by Foswiki::WebFilter::new at line 22, avg 8µs/call
sub Foswiki::WebFilter::CORE:regcomp; # opcode