make code C++ warning clean (again)
[libfirm] / scripts / statev_examples / spilltime.pl
1 #!/usr/bin/perl -w
2
3 use DBI;
4
5 require "plottools.pl";
6
7 # Connect to database
8 $dbase = "dbi:SQLite:dbname=example2.db";
9 $dbh   = DBI->connect($dbase, "", "", { RaiseError => 1}) or die $dbh->errstr;
10
11 # Do database query
12 $querys = "SELECT sum(e.bemain_insns_before_ra), sum(e.bemain_time_ra_spill)
13 FROM ctx as c, ev as e
14 WHERE e.id = c.id
15 GROUP BY c.bemain_irg";
16 $query = $dbh->prepare($querys) or die $dbh->errstr;
17 $query->execute() or die $dbh->errstr;
18 $data  = $query->fetchall_arrayref();
19 undef $query;
20 $dbh->disconnect();
21
22 # Begin drawing picture
23 print <<'__END__';
24 \begin{tikzpicture}[baseline=(current bounding box.south)]%
25 __END__
26
27 $box_width = 6;
28 $box_height = 4;
29 # Create a picture with size 6cm x 4cm
30 set_picture_size($box_width, $box_height);
31 # Set min and max data values
32 set_data_bounds(0, 0, 1600, 25);
33 # alternatively: determine bounds from data
34 # set_data_bounds_from_data($data);
35
36 # Draw the box, with x tikz at 200 units distance, y tikz in 5 units
37 outputbox(200, 5);
38
39 # Draw an X and Y label
40 $label_x = $box_width / 2;
41 $label_y = $box_height / 2;
42 print <<__EOF__;
43         \\node at ($label_x, -0.6) { Number of Instructions };
44         \\node[rotate=90] at (-0.65, $label_y) { Spill Time [msec.] };
45 __EOF__
46
47 # Setup for plotting
48 print <<__EOF__;
49         \\pgfplothandlermark{\\pgfuseplotmark{+}}
50         \\color{black}
51 __EOF__
52
53 # Draw values
54 plot($data);
55
56 # Draw linear regression line
57 draw_regression($data, "densely dashed, color=white");
58
59 # Finish the picture
60 print <<__EOF__;
61 \\end{tikzpicture}%
62 __EOF__