OLD | NEW |
(Empty) | |
| 1 #!/bin/tclsh |
| 2 # |
| 3 # Run this script in the same directory as the "vdbe_profile.out" file. |
| 4 # This script summarizes the results contained in that file. |
| 5 # |
| 6 if {![file readable vdbe_profile.out]} { |
| 7 error "run this script in the same directory as the vdbe_profile.out file" |
| 8 } |
| 9 set in [open vdbe_profile.out r] |
| 10 set stmt {} |
| 11 set allstmt {} |
| 12 while {![eof $in]} { |
| 13 set line [gets $in] |
| 14 if {$line==""} continue |
| 15 if {[regexp {^---- } $line]} { |
| 16 set stmt [lindex $line 1] |
| 17 if {[info exists cnt($stmt)]} { |
| 18 incr cnt($stmt) |
| 19 set firsttime 0 |
| 20 } else { |
| 21 set cnt($stmt) 1 |
| 22 set sql($stmt) {} |
| 23 set firsttime 1 |
| 24 lappend allstmt $stmt |
| 25 } |
| 26 continue; |
| 27 } |
| 28 if {[regexp {^-- } $line]} { |
| 29 if {$firsttime} { |
| 30 append sql($stmt) [string range $line 3 end]\n |
| 31 } |
| 32 continue |
| 33 } |
| 34 if {![regexp {^ *\d+ *\d+ *\d+ *\d+ ([A-Z].*)} $line all detail]} continue |
| 35 set c [lindex $line 0] |
| 36 set t [lindex $line 1] |
| 37 set addr [lindex $line 3] |
| 38 set op [lindex $line 4] |
| 39 if {[info exists opcnt($op)]} { |
| 40 incr opcnt($op) $c |
| 41 incr opcycle($op) $t |
| 42 } else { |
| 43 set opcnt($op) $c |
| 44 set opcycle($op) $t |
| 45 } |
| 46 if {[info exists stat($stmt,$addr)]} { |
| 47 foreach {cx tx detail} $stat($stmt,$addr) break |
| 48 incr cx $c |
| 49 incr tx $t |
| 50 set stat($stmt,$addr) [list $cx $tx $detail] |
| 51 } else { |
| 52 set stat($stmt,$addr) [list $c $t $detail] |
| 53 } |
| 54 } |
| 55 close $in |
| 56 |
| 57 foreach stmt $allstmt { |
| 58 puts "********************************************************************" |
| 59 puts [string trim $sql($stmt)] |
| 60 puts "Execution count: $cnt($stmt)" |
| 61 for {set i 0} {[info exists stat($stmt,$i)]} {incr i} { |
| 62 foreach {cx tx detail} $stat($stmt,$i) break |
| 63 if {$cx==0} { |
| 64 set ax 0 |
| 65 } else { |
| 66 set ax [expr {$tx/$cx}] |
| 67 } |
| 68 puts [format {%8d %12d %12d %4d %s} $cx $tx $ax $i $detail] |
| 69 } |
| 70 } |
| 71 puts "********************************************************************" |
| 72 puts "OPCODES:" |
| 73 foreach op [lsort [array names opcnt]] { |
| 74 set cx $opcnt($op) |
| 75 set tx $opcycle($op) |
| 76 if {$cx==0} { |
| 77 set ax 0 |
| 78 } else { |
| 79 set ax [expr {$tx/$cx}] |
| 80 } |
| 81 puts [format {%8d %12d %12d %s} $cx $tx $ax $op] |
| 82 } |
OLD | NEW |