Filename | /Users/ap13/perl5/lib/perl5/Graph/Matrix.pm |
Statements | Executed 3 statements in 278µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 21µs | 48µs | BEGIN@6 | Graph::Matrix::
0 | 0 | 0 | 0s | 0s | get | Graph::Matrix::
0 | 0 | 0 | 0s | 0s | new | Graph::Matrix::
0 | 0 | 0 | 0s | 0s | set | Graph::Matrix::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Graph::Matrix; | ||||
2 | |||||
3 | # $SIG{__DIE__ } = sub { use Carp; confess }; | ||||
4 | # $SIG{__WARN__} = sub { use Carp; confess }; | ||||
5 | |||||
6 | 2 | 274µs | 2 | 76µs | # spent 48µs (21+27) within Graph::Matrix::BEGIN@6 which was called:
# once (21µs+27µs) by Graph::AdjacencyMatrix::BEGIN@6 at line 6 # spent 48µs making 1 call to Graph::Matrix::BEGIN@6
# spent 27µs making 1 call to strict::import |
7 | |||||
8 | sub new { | ||||
9 | my ($class, $g) = @_; | ||||
10 | my @V = $g->vertices; | ||||
11 | my $V = @V; | ||||
12 | my %V; @V{ @V } = 0 .. $#V; | ||||
13 | bless [ [ map { [ ] } 0 .. $#V ], \%V ], $class; | ||||
14 | } | ||||
15 | |||||
16 | sub set { | ||||
17 | my ($m, $u, $v, $val) = @_; | ||||
18 | my ($i, $j) = map { $m->[1]->{ $_ } } ($u, $v); | ||||
19 | $m->[0]->[$i]->[$j] = $val; | ||||
20 | } | ||||
21 | |||||
22 | sub get { | ||||
23 | my ($m, $u, $v) = @_; | ||||
24 | my ($i, $j) = map { $m->[1]->{ $_ } } ($u, $v); | ||||
25 | $m->[0]->[$i]->[$j]; | ||||
26 | } | ||||
27 | |||||
28 | 1 | 4µs | 1; | ||
29 | __END__ |