5 require "plottools.pl";
8 $dbase = "dbi:SQLite:dbname=example2.db";
9 $dbh = DBI->connect($dbase, "", "", { RaiseError => 1}) or die $dbh->errstr;
12 $querys = "SELECT sum(e.bemain_insns_before_ra), sum(e.bemain_time_ra_spill)
13 FROM ctx as c, ev as e
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();
22 # Begin drawing picture
24 \begin{tikzpicture}[baseline=(current bounding box.south)]%
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);
36 # Draw the box, with x tikz at 200 units distance, y tikz in 5 units
39 # Draw an X and Y label
40 $label_x = $box_width / 2;
41 $label_y = $box_height / 2;
43 \\node at ($label_x, -0.6) { Number of Instructions };
44 \\node[rotate=90] at (-0.65, $label_y) { Spill Time [msec.] };
49 \\pgfplothandlermark{\\pgfuseplotmark{+}}
56 # Draw linear regression line
57 draw_regression($data, "densely dashed, color=white");