X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5b3677b425b9cc6949c1573d59ac772540cbf4b2..84402e8e2ee2a2d0bef25fdceb0a263ed8b471f6:/tools/MSG_visualization/trace2fig.pl diff --git a/tools/MSG_visualization/trace2fig.pl b/tools/MSG_visualization/trace2fig.pl index cd23d39cec..0abc7ab498 100755 --- a/tools/MSG_visualization/trace2fig.pl +++ b/tools/MSG_visualization/trace2fig.pl @@ -1,19 +1,20 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl -# Copyright (c) 2006-2007, 2014. The SimGrid Team. +# Copyright (c) 2006-2020. The SimGrid Team. # All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. use strict; +use warnings; + #use Data::Dumper; use XFig; use POSIX; -my($grid_Y_size)=225; -my($grid_X_size)=100550; # Can be changed to improve readability in - # function of the total execution time +my($grid_Y_size)=225; +my($grid_X_size)=100550; # Can be changed to improve readability in function of the total execution time my($color_suspended)=1; my($color_compute)=2; @@ -23,9 +24,6 @@ my($color_communicate)=4; # Determine the order of the colors in the legend my(@color_list)=($color_compute,$color_communicate,$color_wait_for_recpt,$color_suspended); - - - sub read_cat { my(%Cat); my($filename)=@_; @@ -49,7 +47,6 @@ sub read_cat { return \%Cat; } - sub read_event { my($filename,$Cat)=@_; my($line); @@ -89,37 +86,35 @@ sub read_link { } if($line =~ /^17\s/) { my($event,$date,$type,$father,$channel,$dst,$key,$trash) = split(/\t+/,$line); - my($numkey)=hex "$key"; + my($numkey)=hex "$key"; while (defined($link{$numkey}{dst})) {$numkey++;} $link{$numkey}{dst}=$dst; - $link{$numkey}{dst_date}=$date; + $link{$numkey}{dst_date}=$date; } } close INPUT; return \%link; } - sub build_cat_tree { my($root,$Cat)=@_; - my(@childs)=(); + my(@children)=(); my($cat); foreach $cat (keys %$Cat) { if($$Cat{$cat}{father} eq $root) { - push @childs, build_cat_tree($cat,$Cat); + push @children, build_cat_tree($cat,$Cat); } # print "$$Cat{$cat}{name}\t\t $Cat{$cat}{father}\n"; } - - return [$root,@childs]; + return [$root,@children]; } sub build_cat_list { my($tree,$cat_list)=@_; my($root) = shift @$tree; my($u); - + push @$cat_list,$root; foreach $u (@$tree) { @@ -128,7 +123,6 @@ sub build_cat_list { unshift @$tree, $root; } - sub cat_sorting_function { my($cat1,$cat2,$Cat)=@_; if (!defined($$Cat{$cat1}{state})) { @@ -207,7 +201,7 @@ sub draw_cat { my($cat,$e,$link); my($max_string_length)=0; foreach $cat (keys %$Cat) { - next unless (defined($$Cat{$cat}{Y_min}) && + next unless (defined($$Cat{$cat}{Y_min}) && defined($$Cat{$cat}{Y_max})); my($text) = new XFig ('text'); # $text->{'text'} = "$$Cat{$$Cat{$cat}{father}}{name}"."$$Cat{$cat}{name}"; @@ -225,8 +219,7 @@ sub draw_cat { my($max_date)=0; foreach $cat (keys %$Cat) { - next unless (defined($$Cat{$cat}{Y_min}) && - defined($$Cat{$cat}{Y_max})); + next unless (defined($$Cat{$cat}{Y_min}) && defined($$Cat{$cat}{Y_max})); my(@states)=(); my($e); foreach $e (@{$$Cat{$cat}{state}}) { @@ -242,8 +235,7 @@ sub draw_cat { $state = $$old_event[1]; # LM: I added the next line because of "undefined values"... -# normally, I think that this should not happen, but this part of code -# is a bit too cryptic to me +# normally, I think that this should not happen, but this part of code is a bit too cryptic to me next unless (defined($state)); my($line) = new XFig ('polyline'); @@ -281,18 +273,15 @@ sub draw_cat { print STDERR "$link: $src ($src_date) -> $dst ($dst_date)\n"; print STDERR "$$Cat{$src}{name} -> $$Cat{$dst}{name}\n"; - $line->{'points'} = [ [$src_date*$grid_X_size, + $line->{'points'} = [ [$src_date*$grid_X_size, ($$Cat{$src}{Y_min}+$$Cat{$src}{Y_max})/2*$grid_Y_size], - [$dst_date*$grid_X_size, + [$dst_date*$grid_X_size, ($$Cat{$dst}{Y_min}+$$Cat{$dst}{Y_max})/2*$grid_Y_size] ]; $line->{'forwardarrow'} = ['1', '1', '1.00', '60.00', '120.00']; $fig->add ($line); } - - # Host visualization - my($max_Y)= 0; my($index_fill)=0; @@ -301,11 +290,10 @@ sub draw_cat { my($host_text_x)= $min_x_for_host + 200; foreach $cat (keys %$Cat) { - next unless (defined($$Cat{$cat}{Y_min_host}) && - defined($$Cat{$cat}{Y_max_host})); + next unless (defined($$Cat{$cat}{Y_min_host}) && defined($$Cat{$cat}{Y_max_host})); my($line) = new XFig ('polyline'); - $line->{'depth'} = 150; + $line->{'depth'} = 150; $line->{'subtype'} = 1; # line $line->{'points'} = [ [$min_x_for_host, $$Cat{$cat}{Y_min_host}*$grid_Y_size], [$max_date*$grid_X_size+150, $$Cat{$cat}{Y_min_host}*$grid_Y_size], @@ -342,7 +330,7 @@ sub draw_cat { my($line) = new XFig ('polyline'); - $line->{'depth'} = 50; + $line->{'depth'} = 50; $line->{'subtype'} = 1; # line $line->{'points'} = [ [$min_x,$min_Y + ($i-1)*$height ], [$min_x + $width,$min_Y + ($i-1)*$height], @@ -374,16 +362,15 @@ sub draw_cat { $fig->add ($text); $i++; } - + # Time axis - my($line) = new XFig ('polyline'); - $line->{'depth'} = 0; + $line->{'depth'} = 0; $line->{'subtype'} = 1; # line $line->{'points'} = [ [0,0],[$max_date * $grid_X_size+150,0] ]; $line->{'forwardarrow'} = ['1', '1', '1.00', '60.00', '120.00']; $fig->add ($line); - + my($digits)=POSIX::floor(log($max_date)/log(10)); my($exponent) = 10**$digits; my($mantissa)= $max_date / $exponent; @@ -401,7 +388,7 @@ sub draw_cat { for($x=0; $x < $max_date; $x += $incr) { print "$x\n"; $line = new XFig ('polyline'); - $line->{'depth'} = 0; + $line->{'depth'} = 0; $line->{'subtype'} = 1; # line $line->{'points'} = [ [$x * $grid_X_size,0],[$x * $grid_X_size, -100] ]; $line->{'forwardarrow'} = 0; @@ -417,12 +404,11 @@ sub draw_cat { # Empty line so that the text of the time axis can be seen on the pdf $line = new XFig ('polyline'); - $line->{'depth'} = 999; + $line->{'depth'} = 999; $line->{'subtype'} = 1; # line - $line->{'thickness'} = 0; + $line->{'thickness'} = 0; $line->{'points'} = [ [0,0],[0, -400] ]; $fig->add ($line); - } sub main { @@ -439,7 +425,6 @@ sub main { # print "@$cat_list \n"; set_cat_position($Cat,$cat_list); - my($fig)=create_fig("toto.fig"); draw_cat($fig,$Cat,$Link); $fig->writefile ();