← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 19:05:14 2015
Reported on Fri Jul 31 19:08:09 2015

Filename/var/www/foswiki11/lib/Foswiki/Iterator.pm
StatementsExecuted 56 statements in 9.17ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4011702µs798µsFoswiki::Iterator::::resetFoswiki::Iterator::reset
11133µs52µsFoswiki::Iterator::::allFoswiki::Iterator::all
11112µs30µsFoswiki::Iterator::::BEGIN@21Foswiki::Iterator::BEGIN@21
11111µs16µsFoswiki::Iterator::::BEGIN@22Foswiki::Iterator::BEGIN@22
1118µs24µsFoswiki::Iterator::::BEGIN@23Foswiki::Iterator::BEGIN@23
1117µs36µsFoswiki::Iterator::::BEGIN@26Foswiki::Iterator::BEGIN@26
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
21225µs247µs
# spent 30µs (12+18) within Foswiki::Iterator::BEGIN@21 which was called: # once (12µs+18µs) by Foswiki::AggregateIterator::BEGIN@16 at line 21
use strict;
# spent 30µs making 1 call to Foswiki::Iterator::BEGIN@21 # spent 18µs making 1 call to strict::import
22223µs220µs
# spent 16µs (11+5) within Foswiki::Iterator::BEGIN@22 which was called: # once (11µs+5µs) by Foswiki::AggregateIterator::BEGIN@16 at line 22
use warnings;
# spent 16µs making 1 call to Foswiki::Iterator::BEGIN@22 # spent 5µs making 1 call to warnings::import
23226µs240µs
# spent 24µs (8+16) within Foswiki::Iterator::BEGIN@23 which was called: # once (8µs+16µs) by Foswiki::AggregateIterator::BEGIN@16 at line 23
use Assert;
# spent 24µs making 1 call to Foswiki::Iterator::BEGIN@23 # spent 16µs making 1 call to Assert::import
24
25#debug Iterators
262149µs264µs
# spent 36µs (7+29) within Foswiki::Iterator::BEGIN@26 which was called: # once (7µs+29µs) by Foswiki::AggregateIterator::BEGIN@16 at line 26
use constant MONITOR => 0;
# spent 36µs making 1 call to Foswiki::Iterator::BEGIN@26 # spent 29µs making 1 call to constant::import
27
28=begin TML
29
30---++ hasNext() -> $boolean
31
32Returns true if the iterator has more items, or false when the iterator
33is exhausted.
34
35=cut
36
37sub hasNext { ASSERT('Pure virtual function called') if DEBUG; }
38
39=begin TML
40
41---++ next() -> $data
42
43Return the next data in the iteration.
44
45The data may be any type.
46
47The iterator object can be customised to pre- and post-process entries from
48the list before returning them. This is done by setting two fields in the
49iterator object:
50
51 * ={filter}= can be defined to be a sub that filters each entry. The entry
52 will be ignored (next() will not return it) if the filter returns false.
53 * ={process}= can be defined to be a sub to process each entry before it
54 is returned by next. The value returned from next is the value returned
55 by the process function.
56
57=cut
58
59sub next { ASSERT('Pure virtual function called') if DEBUG; }
60
61=begin TML
62
63---++ reset() -> $boolean
64
65resets the iterator to the begining - returns false if it can't
66
67=cut
68
69408.93ms4096µs
# spent 798µs (702+96) within Foswiki::Iterator::reset which was called 40 times, avg 20µs/call: # 40 times (702µs+96µs) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 208 of /var/www/foswiki11/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm, avg 20µs/call
sub reset { ASSERT('Pure virtual function called') if DEBUG; }
# spent 96µs making 40 calls to Assert::ASSERTS_OFF, avg 2µs/call
70
71=begin TML
72
73---++ ObjectMethod all() -> @list
74
75Exhaust the iterator. Return all remaining elements in the iteration
76as a list. The returned list should be considered to be immutable.
77
78The default implementation simply runs the iterator to its end.
79
80=cut
81
82
# spent 52µs (33+19) within Foswiki::Iterator::all which was called: # once (33µs+19µs) by Foswiki::UI::View::revisionsAround at line 441 of /var/www/foswiki11/lib/Foswiki/UI/View.pm
sub all {
8311µs my ($this) = @_;
841400ns my @remains;
8513µs16µs while ( $this->hasNext() ) {
# spent 6µs making 1 call to Foswiki::Iterator::NumberRangeIterator::hasNext
86310µs613µs push( @remains, $this->next() );
# spent 8µs making 3 calls to Foswiki::Iterator::NumberRangeIterator::next, avg 3µs/call # spent 5µs making 3 calls to Foswiki::Iterator::NumberRangeIterator::hasNext, avg 2µs/call
87 }
8816µs return @remains;
89}
90
9112µs1;
92__END__