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

Filename/var/www/foswikidev/core/lib/Foswiki/Iterator.pm
StatementsExecuted 57 statements in 625µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4011244µs244µsFoswiki::Iterator::::resetFoswiki::Iterator::reset
11124µs42µsFoswiki::Iterator::::allFoswiki::Iterator::all
11112µs36µsFoswiki::Iterator::::BEGIN@23Foswiki::Iterator::BEGIN@23
11112µs24µsFoswiki::Iterator::::BEGIN@21Foswiki::Iterator::BEGIN@21
1118µs42µsFoswiki::Iterator::::BEGIN@26Foswiki::Iterator::BEGIN@26
1118µs11µsFoswiki::Iterator::::BEGIN@22Foswiki::Iterator::BEGIN@22
1114µs4µsFoswiki::Iterator::::BEGIN@28Foswiki::Iterator::BEGIN@28
0000s0sFoswiki::Iterator::::hasNextFoswiki::Iterator::hasNext
0000s0sFoswiki::Iterator::::nextFoswiki::Iterator::next
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::Iterator
6
7This class cannot be instantiated on its own - it is an interface
8specification for iterators. See http://en.wikipedia.org/wiki/Iterator_Pattern
9for more information on the iterator pattern.
10
11The interface only supports forward iteration. Subclasses should use this
12as their base class (so that =$it->isa("Foswiki::Iterator")= returns true),
13and must implement =hasNext= and =next= per the specification below.
14
15See Foswiki::ListIterator for an example implementation.
16
17=cut
18
19package Foswiki::Iterator;
20
21224µs235µs
# spent 24µs (12+11) within Foswiki::Iterator::BEGIN@21 which was called: # once (12µs+11µs) by Foswiki::AggregateIterator::BEGIN@16 at line 21
use strict;
# spent 24µs making 1 call to Foswiki::Iterator::BEGIN@21 # spent 12µs making 1 call to strict::import
22221µs215µs
# spent 11µs (8+4) within Foswiki::Iterator::BEGIN@22 which was called: # once (8µs+4µs) by Foswiki::AggregateIterator::BEGIN@16 at line 22
use warnings;
# spent 11µs making 1 call to Foswiki::Iterator::BEGIN@22 # spent 4µs making 1 call to warnings::import
23228µs259µs
# spent 36µs (12+23) within Foswiki::Iterator::BEGIN@23 which was called: # once (12µs+23µs) by Foswiki::AggregateIterator::BEGIN@16 at line 23
use Assert;
# spent 36µs making 1 call to Foswiki::Iterator::BEGIN@23 # spent 23µs making 1 call to Exporter::import
24
25#debug Iterators
26250µs276µs
# spent 42µs (8+34) within Foswiki::Iterator::BEGIN@26 which was called: # once (8µs+34µs) by Foswiki::AggregateIterator::BEGIN@16 at line 26
use constant MONITOR => 0;
# spent 42µs making 1 call to Foswiki::Iterator::BEGIN@26 # spent 34µs making 1 call to constant::import
27
28
# spent 4µs within Foswiki::Iterator::BEGIN@28 which was called: # once (4µs+0s) by Foswiki::AggregateIterator::BEGIN@16 at line 33
BEGIN {
2915µs if ( $Foswiki::cfg{UseLocale} ) {
30 require locale;
31 import locale();
32 }
331150µs14µs}
# spent 4µs making 1 call to Foswiki::Iterator::BEGIN@28
34
35=begin TML
36
37---++ hasNext() -> $boolean
38
39Returns true if the iterator has more items, or false when the iterator
40is exhausted.
41
42=cut
43
44sub hasNext { ASSERT('Pure virtual function called') if DEBUG; }
45
46=begin TML
47
48---++ next() -> $data
49
50Return the next data in the iteration.
51
52The data may be any type.
53
54The iterator object can be customised to pre- and post-process entries from
55the list before returning them. This is done by setting two fields in the
56iterator object:
57
58 * ={filter}= can be defined to be a sub that filters each entry. The entry
59 will be ignored (next() will not return it) if the filter returns false.
60 * ={process}= can be defined to be a sub to process each entry before it
61 is returned by next. The value returned from next is the value returned
62 by the process function.
63
64=cut
65
66sub next { ASSERT('Pure virtual function called') if DEBUG; }
67
68=begin TML
69
70---++ reset() -> $boolean
71
72resets the iterator to the begining - returns false if it can't
73
74=cut
75
7640326µs
# spent 244µs within Foswiki::Iterator::reset which was called 40 times, avg 6µs/call: # 40 times (244µs+0s) by Foswiki::Iterator::FilterIterator::reset at line 137 of /var/www/foswikidev/core/lib/Foswiki/Iterator/FilterIterator.pm, avg 6µs/call
sub reset { ASSERT('Pure virtual function called') if DEBUG; }
77
78=begin TML
79
80---++ ObjectMethod all() -> @list
81
82Exhaust the iterator. Return all remaining elements in the iteration
83as a list. The returned list should be considered to be immutable.
84
85The default implementation simply runs the iterator to its end.
86
87=cut
88
89
# spent 42µs (24+18) within Foswiki::Iterator::all which was called: # once (24µs+18µs) by Foswiki::UI::View::revisionsAround at line 508 of /var/www/foswikidev/core/lib/Foswiki/UI/View.pm
sub all {
9011µs my ($this) = @_;
911500ns my @remains;
9217µs19µs while ( $this->hasNext() ) {
# spent 9µs making 1 call to Foswiki::Iterator::NumberRangeIterator::hasNext
9337µs610µs push( @remains, $this->next() );
# spent 5µs making 3 calls to Foswiki::Iterator::NumberRangeIterator::next, avg 2µs/call # spent 4µs making 3 calls to Foswiki::Iterator::NumberRangeIterator::hasNext, avg 2µs/call
94 }
9514µs return @remains;
96}
97
9812µs1;
99__END__