5 use Time::HiRes qw /usleep/;
10 &GetOptions("period=i"=>\$period, "numtimes=i"=>\$numtimes);
12 $#ARGV==0 or die "v3_guest_mem_track_viz.pl [--numtimes=num(-1=forever)] [--period=milliseconds] /dev/v3-vmN\n";
16 open(G,"|gnuplot") or die "Cannot open gnuplot\n";
22 $data = `v3_guest_mem_track $vm snapshot text _`;
24 $data=~/Cores:\s*(\d+)/ or die "Cannot parse for cores\n";
27 $data=~/Pages:\s*(\d+)/ or die "Cannot parse for pages\n";
32 for ($core=0;$core<$numcores;$core++) {
33 $data=~/Core\s+$core\s+\(.*\)\s+\:\s+(\S+)/ or die "Cannot parse core $core\n";
37 $side=int(sqrt($numpages));
40 $y=int($numpages/$side);
42 print G "set xrange [0:$x]\n";
43 print G "set yrange [0:$y]\n";
45 print G "plot ", join(",", map {"'-' using 1:2 with points title 'core $_' "} (0..$numcores-1) ),"\n";
46 for ($core=0;$core<$numcores;$core++) {
47 for ($i=0;$i<$numpages;$i++) {
48 # print substr($bits,$i,1);
49 if (substr($bits[$core],$i,1) eq "X") {
50 print G join("\t", int($i/$side), $i % $side), "\n";
61 print "Hit enter to finish\n";