4 # Run this script in the same directory as the "vdbe_profile.out" file.
5 # This script summarizes the results contained in that file.
8 # Compile SQLite using the -DVDBE_PROFILE option on Linux. This causes
9 # performance information about individual VDBE operations to be appended
10 # to the "vdbe_profile.out" file. After content has been accumulated in
11 # vdbe_profile.out, run this script to analyze the output and generate a
14 if {![file readable vdbe_profile.out
]} {
15 error "run this script in the same directory as the vdbe_profile.out file"
17 set in
[open vdbe_profile.out r
]
22 if {$line==""} continue
23 if {[regexp {^
---- } $line]} {
24 set stmt
[lindex $line 1]
25 if {[info exists cnt
($stmt)]} {
36 if {[regexp {^
-- } $line]} {
38 append sql
($stmt) [string range
$line 3 end
]\n
42 if {![regexp {^
*\d
+ *\d
+ *\d
+ *\d
+ ([A-Z
].
*)} $line all detail
]} continue
43 set c
[lindex $line 0]
44 set t
[lindex $line 1]
45 set addr
[lindex $line 3]
46 set op
[lindex $line 4]
47 if {[info exists opcnt
($op)]} {
54 if {[info exists stat
($stmt,$addr)]} {
55 foreach {cx tx detail
} $stat($stmt,$addr) break
58 set stat
($stmt,$addr) [list $cx $tx $detail]
60 set stat
($stmt,$addr) [list $c $t $detail]
65 foreach stmt
$allstmt {
66 puts "********************************************************************"
67 puts [string trim
$sql($stmt)]
68 puts "Execution count: $cnt($stmt)"
71 for {set i
0} {[info exists stat
($stmt,$i)]} {incr i
} {
72 foreach {cx tx detail
} $stat($stmt,$i) break
76 set ax
[expr {$tx/$cx}]
78 puts [format {%8d
%12d
%12d
%4d
%s
} $cx $tx $ax $i $detail]
82 set tax
[expr {$tcx>0?
$ttx/$tcx:0}]
83 puts [format {%8d
%12d
%12d TOTAL
} $tcx $ttx $tax]
85 puts "********************************************************************"
87 foreach op
[lsort [array names opcnt
]] {
93 set ax
[expr {$tx/$cx}]
95 puts [format {%8d
%12d
%12d
%s
} $cx $tx $ax $op]