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

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plurals.pm
StatementsExecuted 103 statements in 997µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2211415µs519µsFoswiki::Plurals::::singularFormFoswiki::Plurals::singularForm
287165µs65µsFoswiki::Plurals::::CORE:substFoswiki::Plurals::CORE:subst (opcode)
221139µs39µsFoswiki::Plurals::::CORE:matchFoswiki::Plurals::CORE:match (opcode)
11135µs46µsFoswiki::Plurals::::BEGIN@13Foswiki::Plurals::BEGIN@13
11131µs66µsFoswiki::Plurals::::BEGIN@14Foswiki::Plurals::BEGIN@14
11127µs99µsFoswiki::Plurals::::BEGIN@15Foswiki::Plurals::BEGIN@15
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
2
3=begin TML
4
5---+ package Foswiki::Plurals
6
7Handle conversion of plural topic names to singular form.
8
9=cut
10
11package Foswiki::Plurals;
12
13263µs258µs
# spent 46µs (35+12) within Foswiki::Plurals::BEGIN@13 which was called: # once (35µs+12µs) by Foswiki::Render::_renderWikiWord at line 13
use strict;
# spent 46µs making 1 call to Foswiki::Plurals::BEGIN@13 # spent 12µs making 1 call to strict::import
14256µs2101µs
# spent 66µs (31+35) within Foswiki::Plurals::BEGIN@14 which was called: # once (31µs+35µs) by Foswiki::Render::_renderWikiWord at line 14
use warnings;
# spent 66µs making 1 call to Foswiki::Plurals::BEGIN@14 # spent 35µs making 1 call to warnings::import
152347µs2171µs
# spent 99µs (27+72) within Foswiki::Plurals::BEGIN@15 which was called: # once (27µs+72µs) by Foswiki::Render::_renderWikiWord at line 15
use Assert;
# spent 99µs making 1 call to Foswiki::Plurals::BEGIN@15 # spent 72µs making 1 call to Assert::import
16
17=begin TML
18
19---++ StaticMethod singularForm($web, $pluralForm) -> $singularForm
20
21Try to singularise plural topic name.
22 * =$web= - the web the topic must be in
23 * =$pluralForm= - topic name
24Returns undef if no singular form exists, otherwise returns the
25singular form of the topic
26
27I18N - Only apply plural processing if site language is English, or
28if a built-in English-language web. Plurals
29apply to names ending in 's', where topic doesn't exist with plural
30name.
31
32Note that this is highly langauge specific, and need to be enabled
33on a per-installation basis with $Foswiki::cfg{PluralToSingular}.
34
35=cut
36
37
# spent 519µs (415+104) within Foswiki::Plurals::singularForm which was called 22 times, avg 24µs/call: # 22 times (415µs+104µs) by Foswiki::Render::_renderWikiWord at line 610 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Render.pm, avg 24µs/call
sub singularForm {
3896527µs my ( $web, $pluralForm ) = @_;
392243µs $web =~ s#\.#/#go;
# spent 43µs making 22 calls to Foswiki::Plurals::CORE:subst, avg 2µs/call
40
41 # Plural processing only if enabled in configure or one of the
42 # distributed webs
43 return
44 unless ( $Foswiki::cfg{PluralToSingular}
45 or $web eq $Foswiki::cfg{UsersWebName}
46 or $web eq $Foswiki::cfg{SystemWebName} );
472239µs return unless ( $pluralForm =~ /s$/ );
# spent 39µs making 22 calls to Foswiki::Plurals::CORE:match, avg 2µs/call
48
49 # Topic name is plural in form
50 my $singularForm = $pluralForm;
5112µs $singularForm =~ s/ies$/y/; # plurals like policy / policies
# spent 2µs making 1 call to Foswiki::Plurals::CORE:subst
5212µs $singularForm =~ s/sses$/ss/; # plurals like address / addresses
# spent 2µs making 1 call to Foswiki::Plurals::CORE:subst
5313µs $singularForm =~ s/ches$/ch/; # plurals like search / searches
# spent 3µs making 1 call to Foswiki::Plurals::CORE:subst
5413µs $singularForm =~ s/(oes|os)$/o/; # plurals like veto / vetoes
# spent 3µs making 1 call to Foswiki::Plurals::CORE:subst
5515µs $singularForm =~ s/(?<=[Xx])es$//; # plurals like box / boxes
# spent 5µs making 1 call to Foswiki::Plurals::CORE:subst
5618µs $singularForm =~ s/(?<=[^s])s$//; # others, excluding ss like address(es)
# spent 8µs making 1 call to Foswiki::Plurals::CORE:subst
57 return $singularForm;
58}
59
6014µs1;
61__END__
 
# spent 39µs within Foswiki::Plurals::CORE:match which was called 22 times, avg 2µs/call: # 22 times (39µs+0s) by Foswiki::Plurals::singularForm at line 47, avg 2µs/call
sub Foswiki::Plurals::CORE:match; # opcode
# spent 65µs within Foswiki::Plurals::CORE:subst which was called 28 times, avg 2µs/call: # 22 times (43µs+0s) by Foswiki::Plurals::singularForm at line 39, avg 2µs/call # once (8µs+0s) by Foswiki::Plurals::singularForm at line 56 # once (5µs+0s) by Foswiki::Plurals::singularForm at line 55 # once (3µs+0s) by Foswiki::Plurals::singularForm at line 54 # once (3µs+0s) by Foswiki::Plurals::singularForm at line 53 # once (2µs+0s) by Foswiki::Plurals::singularForm at line 51 # once (2µs+0s) by Foswiki::Plurals::singularForm at line 52
sub Foswiki::Plurals::CORE:subst; # opcode