Merge latest trunk changes with this branch.
[sqlite.git] / test / show_speedtest1_rtree.tcl
blob3faa16814696b38670c84ac7cd41e5b996c202f5
1 #!/usr/bin/tclsh
3 # This script displays the field of rectangles used by --testset rtree
4 # of speedtest1. Run this script as follows:
6 # rm test.db
7 # ./speedtest1 --testset rtree --size 25 test.db
8 # sqlite3 --separator ' ' test.db 'SELECT * FROM rt1' >data.txt
9 # wish show_speedtest1_rtree.tcl
11 # The filename "data.txt" is hard coded into this script and so that name
12 # must be used on lines 3 and 4 above. Elsewhere, different filenames can
13 # be used. The --size N parameter can be adjusted as desired.
15 package require Tk
16 set f [open data.txt rb]
17 set data [read $f]
18 close $f
19 canvas .c
20 frame .b
21 button .b.b1 -text X-Y -command refill-xy
22 button .b.b2 -text X-Z -command refill-xz
23 button .b.b3 -text Y-Z -command refill-yz
24 pack .b.b1 .b.b2 .b.b3 -side left
25 pack .c -side top -fill both -expand 1
26 pack .b -side top
27 proc resize_canvas_to_fit {} {
28 foreach {x0 y0 x1 y1} [.c bbox all] break
29 set w [expr {$x1-$x0}]
30 set h [expr {$y1-$y0}]
31 .c config -width $w -height $h
33 proc refill-xy {} {
34 .c delete all
35 foreach {id x0 x1 y0 y1 z0 z1} $::data {
36 .c create rectangle $x0 $y0 $x1 $y1
38 .c scale all 0 0 0.05 0.05
39 resize_canvas_to_fit
41 proc refill-xz {} {
42 .c delete all
43 foreach {id x0 x1 y0 y1 z0 z1} $::data {
44 .c create rectangle $x0 $z0 $x1 $z1
46 .c scale all 0 0 0.05 0.05
47 resize_canvas_to_fit
49 proc refill-yz {} {
50 .c delete all
51 foreach {id x0 x1 y0 y1 z0 z1} $::data {
52 .c create rectangle $y0 $z0 $y1 $z1
54 .c scale all 0 0 0.05 0.05
55 resize_canvas_to_fit
57 refill-xy