line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Declare our package |
2
|
|
|
|
|
|
|
package POE::Devel::Profiler::Visualizer::BasicGraphViz; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# Standard stuff to catch errors |
5
|
1
|
|
|
1
|
|
1073
|
use strict qw(subs vars refs); # Make sure we can't mess up |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings FATAL => 'all'; # Enable warnings to catch errors |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1539
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Initialize our version |
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Okay, we need to receive the arguments |
12
|
|
|
|
|
|
|
sub GET_ARGS { |
13
|
|
|
|
|
|
|
# We don't care! |
14
|
0
|
|
|
0
|
0
|
|
return 1; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# The actual work is here |
18
|
|
|
|
|
|
|
sub OUTPUT { |
19
|
|
|
|
|
|
|
# Get the data structure |
20
|
0
|
|
|
0
|
0
|
|
my( undef, $data ) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Okay, start drawing the graph! |
23
|
0
|
|
|
|
|
|
print "digraph " . fix_label( $data->{'PROGNAME'} ) . " {\n"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Draw the sessions |
26
|
0
|
|
|
|
|
|
foreach my $sess ( keys %{ $data->{'SESSION'} } ) { |
|
0
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
print " subgraph cluster_session_" . fix_label( $sess ) . " {\n"; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Make a nice label |
30
|
0
|
0
|
|
|
|
|
if ( exists $data->{'SESSION'}->{ $sess }->{'ALIASES'} ) { |
31
|
0
|
|
|
|
|
|
my $alias = ( keys %{ $data->{'SESSION'}->{ $sess }->{'ALIASES'} } )[ rand( scalar( keys %{ $data->{'SESSION'}->{ $sess }->{'ALIASES'} } ) ) ]; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
print " label=\"$alias\";\n"; |
33
|
|
|
|
|
|
|
} else { |
34
|
0
|
|
|
|
|
|
print " label=\"Session $sess\";\n"; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# List the states |
38
|
0
|
|
|
|
|
|
foreach my $state ( sort keys %{ $data->{'SESSION'}->{ $sess }->{'STATES'} } ) { |
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
print " ses_" . fix_label( $sess ) . "_" . fix_label( $state ) . " [ label = \"$state\"];\n"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# End of session |
43
|
0
|
|
|
|
|
|
print " }\n\n"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Now, connect the dots! |
47
|
0
|
|
|
|
|
|
foreach my $sess ( keys %{ $data->{'SESSION'} } ) { |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Loop over the states |
49
|
0
|
|
|
|
|
|
foreach my $state ( keys %{ $data->{'SESSION'}->{ $sess }->{'STATES'} } ) { |
|
0
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $label_from = "ses_" . fix_label( $sess ) . "_" . fix_label( $state ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Loop over CALL/YIELD/POST |
53
|
0
|
|
|
|
|
|
foreach my $type ( qw( CALL YIELD POST ) ) { |
54
|
|
|
|
|
|
|
# Did this state do this? |
55
|
0
|
0
|
|
|
|
|
if ( ! exists $data->{'SESSION'}->{ $sess }->{'STATES'}->{ $state }->{ $type } ) { |
56
|
0
|
|
|
|
|
|
next; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Are we yielding? |
60
|
0
|
0
|
|
|
|
|
if ( $type eq 'YIELD' ) { |
61
|
0
|
|
|
|
|
|
foreach my $yield_state ( keys %{ $data->{'SESSION'}->{ $sess }->{'STATES'}->{ $state }->{ $type } } ) { |
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# About time! |
63
|
0
|
|
|
|
|
|
my $label_to = "ses_" . fix_label( $sess ) . "_" . fix_label( $yield_state ); |
64
|
0
|
|
|
|
|
|
print " $label_from -> $label_to;\n"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} else { |
67
|
|
|
|
|
|
|
# Loop over all call/post |
68
|
0
|
|
|
|
|
|
foreach my $ID ( keys %{ $data->{'SESSION'}->{ $sess }->{'STATES'}->{ $state }->{ $type } } ) { |
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Now, we got the ID, loop over the states |
70
|
0
|
|
|
|
|
|
foreach my $ID_state ( keys %{ $data->{'SESSION'}->{ $sess }->{'STATES'}->{ $state }->{ $type }->{ $ID } } ) { |
|
0
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# About time! |
72
|
0
|
|
|
|
|
|
print " $label_from -> ses_" . fix_label( $ID ) . "_" . fix_label( $ID_state ) . ";\n"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# End the graph! |
81
|
0
|
|
|
|
|
|
print "}\n"; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Fixes annoying label typos |
85
|
|
|
|
|
|
|
sub fix_label { |
86
|
0
|
|
|
0
|
0
|
|
my $label = shift; |
87
|
0
|
|
|
|
|
|
$label =~ s/\W+/_/g; |
88
|
0
|
|
|
|
|
|
return $label; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# End of module |
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
__END__ |