| 1 | package TUI::Gadgets::HeapView; | ||||||||||||||
| 2 | # ABSTRACT: heap view which display the current heap space | ||||||||||||||
| 3 | |||||||||||||||
| 4 | 4 | ▶ | use 5.010; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 4 | our $VERSION = '2.000002'; | |||||||||||||
| 9 | 4 | $VERSION =~ tr/_//d; | |||||||||||||
| 10 | 4 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||||||
| 11 | |||||||||||||||
| 12 | 4 | ▶ | use Exporter 'import'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 4 | our @EXPORT = qw( | |||||||||||||
| 14 | THeapView | ||||||||||||||
| 15 | new_THeapView | ||||||||||||||
| 16 | ); | ||||||||||||||
| 17 | |||||||||||||||
| 18 | 4 | ▶ | use TUI::toolkit; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | 4 | ▶ | use TUI::toolkit::Types qw( :Object ); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | |||||||||||||||
| 21 | 4 | ▶ | use TUI::Views::DrawBuffer; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 22 | 4 | ▶ | use TUI::Views::View; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 23 | |||||||||||||||
| 24 | sub THeapView() { __PACKAGE__ } | ||||||||||||||
| 25 | sub name() { 'THeapView' } | ||||||||||||||
| 26 | 0 | ▶ | sub new_THeapView { __PACKAGE__->from(@_) } | ||||||||||||
|
Subroutine
new_THeapView: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 27 | |||||||||||||||
| 28 | 4 | extends TView; | |||||||||||||
| 29 | |||||||||||||||
| 30 | # private attributes | ||||||||||||||
| 31 | 4 | has oldMem => ( is => 'bare' ); | |||||||||||||
| 32 | 4 | has newMem => ( is => 'bare' ); | |||||||||||||
| 33 | 4 | has heapStr => ( is => 'bare' ); | |||||||||||||
| 34 | |||||||||||||||
| 35 | 0 | ▶ | sub BUILD { # void (\%args) | ||||||||||||
|
Subroutine
BUILD: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||
| 36 | 0 | my ( $self, $args ) = @_; | |||||||||||||
| 37 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 38 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | 0 | $self->{oldMem} = 0; | |||||||||||||
| 40 | 0 | $self->{newMem} = $self->heapSize(); | |||||||||||||
| 41 | 0 | return; | |||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 0 | ▶ | sub draw { # void () | ||||||||||||
|
Subroutine
draw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 45 | 0 | state $sig = signature( | |||||||||||||
| 46 | method => Object, | ||||||||||||||
| 47 | pos => [], | ||||||||||||||
| 48 | ); | ||||||||||||||
| 49 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||
| 50 | |||||||||||||||
| 51 | 0 | my $buf = TDrawBuffer->new(); | |||||||||||||
| 52 | 0 | my $c = $self->getColor( 2 ); | |||||||||||||
| 53 | |||||||||||||||
| 54 | 0 | $buf->moveChar( 0, ' ', $c, $self->{size}{x} ); | |||||||||||||
| 55 | 0 | $buf->moveStr( 0, $self->{heapStr}, $c ); | |||||||||||||
| 56 | 0 | $self->writeLine( 0, 0, $self->{size}{x}, 1, $buf ); | |||||||||||||
| 57 | 0 | return; | |||||||||||||
| 58 | } #/ sub draw | ||||||||||||||
| 59 | |||||||||||||||
| 60 | 0 | ▶ | sub update { # void () | ||||||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 61 | 0 | state $sig = signature( | |||||||||||||
| 62 | method => Object, | ||||||||||||||
| 63 | pos => [], | ||||||||||||||
| 64 | ); | ||||||||||||||
| 65 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||
| 66 | |||||||||||||||
| 67 | 0 | ▶ | if ( ( $self->{newMem} = $self->heapSize() ) != $self->{oldMem} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 68 | 0 | $self->{oldMem} = $self->{newMem}; | |||||||||||||
| 69 | 0 | $self->drawView(); | |||||||||||||
| 70 | } | ||||||||||||||
| 71 | 0 | return; | |||||||||||||
| 72 | } #/ sub update | ||||||||||||||
| 73 | |||||||||||||||
| 74 | 0 | ▶ | sub heapSize { # $total () | ||||||||||||
|
Subroutine
heapSize: not called CC=3 SCAR=20.3
Pod
documented
| |||||||||||||||
| 75 | 4 | ▶ | no warnings 'redefine'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 76 | 0 | ▶ | if ( $^O eq 'MSWin32' ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 77 | 0 | require TUI::Gadgets::HeapView::Win32; | |||||||||||||
| 78 | 0 | *heapSize = \&TUI::Gadgets::HeapView::Win32::heapSize; | |||||||||||||
| 79 | } | ||||||||||||||
| 80 | elsif ( $^O eq 'linux' ) { | ||||||||||||||
| 81 | 0 | require TUI::Gadgets::HeapView::Linux; | |||||||||||||
| 82 | 0 | *heapSize = \&TUI::Gadgets::HeapView::Linux::heapSize; | |||||||||||||
| 83 | } | ||||||||||||||
| 84 | else { | ||||||||||||||
| 85 | 0 | require TUI::Gadgets::HeapView::Unix; | |||||||||||||
| 86 | 0 | *heapSize = \&TUI::Gadgets::HeapView::Unix::heapSize; | |||||||||||||
| 87 | } | ||||||||||||||
| 88 | 0 | goto &heapSize; | |||||||||||||
| 89 | } | ||||||||||||||
| 90 | |||||||||||||||
| 91 | 4 | 1 | |||||||||||||
| 92 | |||||||||||||||
| 93 | __END__ | ||||||||||||||