← 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/Iterator/MergeEventIterator.pm
StatementsExecuted 10 statements in 335µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11113µs25µsFoswiki::Iterator::MergeEventIterator::::BEGIN@4Foswiki::Iterator::MergeEventIterator::BEGIN@4
11111µs15µsFoswiki::Iterator::MergeEventIterator::::BEGIN@5Foswiki::Iterator::MergeEventIterator::BEGIN@5
11110µs34µsFoswiki::Iterator::MergeEventIterator::::BEGIN@6Foswiki::Iterator::MergeEventIterator::BEGIN@6
1114µs4µsFoswiki::Iterator::MergeEventIterator::::BEGIN@8Foswiki::Iterator::MergeEventIterator::BEGIN@8
0000s0sFoswiki::Iterator::MergeEventIterator::::hasNextFoswiki::Iterator::MergeEventIterator::hasNext
0000s0sFoswiki::Iterator::MergeEventIterator::::newFoswiki::Iterator::MergeEventIterator::new
0000s0sFoswiki::Iterator::MergeEventIterator::::nextFoswiki::Iterator::MergeEventIterator::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
2package Foswiki::Iterator::MergeEventIterator;
3
4228µs237µs
# spent 25µs (13+12) within Foswiki::Iterator::MergeEventIterator::BEGIN@4 which was called: # once (13µs+12µs) by Foswiki::Logger::PlainFile::BEGIN@38 at line 4
use strict;
# spent 25µs making 1 call to Foswiki::Iterator::MergeEventIterator::BEGIN@4 # spent 12µs making 1 call to strict::import
5224µs219µs
# spent 15µs (11+4) within Foswiki::Iterator::MergeEventIterator::BEGIN@5 which was called: # once (11µs+4µs) by Foswiki::Logger::PlainFile::BEGIN@38 at line 5
use warnings;
# spent 15µs making 1 call to Foswiki::Iterator::MergeEventIterator::BEGIN@5 # spent 4µs making 1 call to warnings::import
6245µs258µs
# spent 34µs (10+24) within Foswiki::Iterator::MergeEventIterator::BEGIN@6 which was called: # once (10µs+24µs) by Foswiki::Logger::PlainFile::BEGIN@38 at line 6
use Assert;
# spent 34µs making 1 call to Foswiki::Iterator::MergeEventIterator::BEGIN@6 # spent 24µs making 1 call to Exporter::import
7
8
# spent 4µs within Foswiki::Iterator::MergeEventIterator::BEGIN@8 which was called: # once (4µs+0s) by Foswiki::Logger::PlainFile::BEGIN@38 at line 13
BEGIN {
916µs if ( $Foswiki::cfg{UseLocale} ) {
10 require locale;
11 import locale();
12 }
131222µs14µs}
# spent 4µs making 1 call to Foswiki::Iterator::MergeEventIterator::BEGIN@8
14
15=begin TML
16
17---++ =Foswiki::Iterator::MergeEventIterator=
18Private subclass of Foswiki::Iterator that
19 * Is passed a array reference of a list of iterator arrays.
20 * Scans across the list of iterators using snoopNext to find the iterator with the lowest timestamp
21 * returns true to hasNext if any iterator has any records available.
22 * returns the record with the lowest timestamp to the next() request.
23
24=cut
25
261500nsrequire Foswiki::Iterator;
2716µsour @ISA = ('Foswiki::Iterator');
28
29sub new {
30 my ( $class, $list ) = @_;
31 my $this = bless(
32 {
33 Itr_list_ref => $list,
34 process => undef,
35 filter => undef,
36 next => undef,
37 },
38 $class
39 );
40 return $this;
41}
42
43=begin TML
44
45---+++ ObjectMethod hasNext() -> $boolean
46Scans all the iterators to determine if any of them have a record available.
47
48=cut
49
50sub hasNext {
51 my $this = shift;
52
53 foreach my $It ( @{ $this->{Itr_list_ref} } ) {
54 return 1 if $It->hasNext();
55 }
56 return 0;
57}
58
59=begin TML
60
61---+++ ObjectMethod next() -> \$hash or @array
62Snoop all of the iterators to find the lowest timestamp record, and return the
63field hash, or field array, depending up on the requested API version.
64
65=cut
66
67sub next {
68 my $this = shift;
69 my $lowIt;
70 my $lowest;
71
72 foreach my $It ( @{ $this->{Itr_list_ref} } ) {
73 next unless $It->hasNext();
74 my $nextRec = @{ $It->snoopNext() }[0];
75 my $epoch = $nextRec->{epoch};
76
77 if ( !defined $lowest || $epoch <= $lowest ) {
78 $lowIt = $It;
79 $lowest = $epoch;
80 }
81 }
82 return $lowIt->next();
83}
84
8513µs1;
86__END__