-#!/usr/bin/perl -w
+#!/usr/bin/env perl
+
+# Copyright (c) 2006-2022. 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;
# 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)=@_;
return \%Cat;
}
-
sub read_event {
my($filename,$Cat)=@_;
my($line);
}
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) {
unshift @$tree, $root;
}
-
sub cat_sorting_function {
my($cat1,$cat2,$Cat)=@_;
if (!defined($$Cat{$cat1}{state})) {
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}";
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}}) {
$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
- next unless (defined($state));
+# 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');
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;
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],
$line->{'thickness'} = 0;
$index_fill++;
$fig->add ($line);
-
+
my($text) = new XFig ('text');
$text->{'text'} = "$$Cat{$cat}{name}";
$text->{'angle'} = 3.14159265/2;
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],
$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;
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;
# 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 {
# print "@$cat_list \n";
set_cat_position($Cat,$cat_list);
-
my($fig)=create_fig("toto.fig");
draw_cat($fig,$Cat,$Link);
$fig->writefile ();