Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/tool/opcodesum.tcl # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / tool / opcodesum.tcl` 34 lines ยท 1091 bytes Raw Blame History 1 #!/usr/bin/tclsh 2 # 3 # Run this script, redirecting input from cachegrind output, to compute the 4 # number of CPU cycles used by each VDBE opcode. 5 # 6 # The cachegrind output should be configured so that it reports a single 7 # column of Ir at the left margin. Ex: 8 # 9 # cg_annotation --show=Ir --auto=yes cachegrind.out.* | tclsh opcodesum.tcl 10 # 11 set currentop x 12 set ncycle(x) 0 13 while {![eof stdin]} { 14 set line [string map {\173 x \175 x \042 x} [gets stdin]] 15 if {[regexp { \. case OP_.*:} $line]} { 16 regexp {OP_(.+):} $line all currentop 17 set ncycle($currentop) 0 18 } elseif {[lindex $line 1]=="default:" 19 && [regexp {really OP_Noop and OP_Explain} $line]} { 20 break 21 } elseif {[lindex $line 0]!="."} { 22 regsub -all {[^0-9]} [lindex $line 0] {} n 23 if {$n!=""} {incr ncycle($currentop) $n} 24 } 25 } 26 unset ncycle(x) 27 set results {} 28 foreach op [lsort [array names ncycle]] { 29 if {$ncycle($op)==0} continue 30 lappend results [list $ncycle($op) $op] 31 } 32 foreach entry [lsort -index 0 -int -decr $results] { 33 puts [format {%-16s %10d} [lindex $entry 1] [lindex $entry 0]] 34 }