| Filename | /usr/local/share/perl/5.18.2/Stream/Buffered/Auto.pm |
| Statements | Executed 7 statements in 196µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 8µs | 17µs | Stream::Buffered::Auto::BEGIN@2 |
| 1 | 1 | 1 | 7µs | 12µs | Stream::Buffered::Auto::BEGIN@3 |
| 1 | 1 | 1 | 6µs | 56µs | Stream::Buffered::Auto::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Stream::Buffered::Auto::new |
| 0 | 0 | 0 | 0s | 0s | Stream::Buffered::Auto::print |
| 0 | 0 | 0 | 0s | 0s | Stream::Buffered::Auto::rewind |
| 0 | 0 | 0 | 0s | 0s | Stream::Buffered::Auto::size |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Stream::Buffered::Auto; | ||||
| 2 | 2 | 20µs | 2 | 26µs | # spent 17µs (8+9) within Stream::Buffered::Auto::BEGIN@2 which was called:
# once (8µs+9µs) by Stream::Buffered::BEGIN@6 at line 2 # spent 17µs making 1 call to Stream::Buffered::Auto::BEGIN@2
# spent 9µs making 1 call to strict::import |
| 3 | 2 | 27µs | 2 | 16µs | # spent 12µs (7+4) within Stream::Buffered::Auto::BEGIN@3 which was called:
# once (7µs+4µs) by Stream::Buffered::BEGIN@6 at line 3 # spent 12µs making 1 call to Stream::Buffered::Auto::BEGIN@3
# spent 4µs making 1 call to warnings::import |
| 4 | 2 | 148µs | 2 | 107µs | # spent 56µs (6+51) within Stream::Buffered::Auto::BEGIN@4 which was called:
# once (6µs+51µs) by Stream::Buffered::BEGIN@6 at line 4 # spent 56µs making 1 call to Stream::Buffered::Auto::BEGIN@4
# spent 51µs making 1 call to base::import |
| 5 | |||||
| 6 | sub new { | ||||
| 7 | my($class, undef, $max_memory_size) = @_; | ||||
| 8 | bless { | ||||
| 9 | _buffer => Stream::Buffered->create('PerlIO'), | ||||
| 10 | _max => $max_memory_size, | ||||
| 11 | }, $class; | ||||
| 12 | } | ||||
| 13 | |||||
| 14 | sub print { | ||||
| 15 | my $self = shift; | ||||
| 16 | $self->{_buffer}->print(@_); | ||||
| 17 | |||||
| 18 | if ($self->{_max} && $self->{_buffer}->size > $self->{_max}) { | ||||
| 19 | my $buf = $self->{_buffer}->{buffer}; | ||||
| 20 | $self->{_buffer} = Stream::Buffered->create('File'), | ||||
| 21 | $self->{_buffer}->print($buf); | ||||
| 22 | delete $self->{_max}; | ||||
| 23 | } | ||||
| 24 | } | ||||
| 25 | |||||
| 26 | sub size { | ||||
| 27 | my $self = shift; | ||||
| 28 | $self->{_buffer}->size; | ||||
| 29 | } | ||||
| 30 | |||||
| 31 | sub rewind { | ||||
| 32 | my $self = shift; | ||||
| 33 | $self->{_buffer}->rewind; | ||||
| 34 | } | ||||
| 35 | |||||
| 36 | 1 | 2µs | 1; |