summaryrefslogtreecommitdiffstats
path: root/tool/opcodesum.tcl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 17:28:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 17:28:19 +0000
commit18657a960e125336f704ea058e25c27bd3900dcb (patch)
tree17b438b680ed45a996d7b59951e6aa34023783f2 /tool/opcodesum.tcl
parentInitial commit. (diff)
downloadsqlite3-upstream.tar.xz
sqlite3-upstream.zip
Adding upstream version 3.40.1.upstream/3.40.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tool/opcodesum.tcl')
-rw-r--r--tool/opcodesum.tcl34
1 files changed, 34 insertions, 0 deletions
diff --git a/tool/opcodesum.tcl b/tool/opcodesum.tcl
new file mode 100644
index 0000000..47dff32
--- /dev/null
+++ b/tool/opcodesum.tcl
@@ -0,0 +1,34 @@
+#!/usr/bin/tclsh
+#
+# Run this script, redirecting input from cachegrind output, to compute the
+# number of CPU cycles used by each VDBE opcode.
+#
+# The cachegrind output should be configured so that it reports a single
+# column of Ir at the left margin. Ex:
+#
+# cg_annotation --show=Ir --auto=yes cachegrind.out.* | tclsh opcodesum.tcl
+#
+set currentop x
+set ncycle(x) 0
+while {![eof stdin]} {
+ set line [string map {\173 x \175 x \042 x} [gets stdin]]
+ if {[regexp { \. case OP_.*:} $line]} {
+ regexp {OP_(.+):} $line all currentop
+ set ncycle($currentop) 0
+ } elseif {[lindex $line 1]=="default:"
+ && [regexp {really OP_Noop and OP_Explain} $line]} {
+ break
+ } elseif {[lindex $line 0]!="."} {
+ regsub -all {[^0-9]} [lindex $line 0] {} n
+ if {$n!=""} {incr ncycle($currentop) $n}
+ }
+}
+unset ncycle(x)
+set results {}
+foreach op [lsort [array names ncycle]] {
+ if {$ncycle($op)==0} continue
+ lappend results [list $ncycle($op) $op]
+}
+foreach entry [lsort -index 0 -int -decr $results] {
+ puts [format {%-16s %10d} [lindex $entry 1] [lindex $entry 0]]
+}