From: drh Date: Thu, 8 Dec 2016 18:36:19 +0000 (+0000) Subject: Update the tool/cg_anno.tcl script to give a summary of cycle counts by X-Git-Tag: version-3.16.0~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23ee9dc3699a141fb368525b3525359c0a7532e1;p=thirdparty%2Fsqlite.git Update the tool/cg_anno.tcl script to give a summary of cycle counts by canonical source file name. FossilOrigin-Name: 254a83bf30c15d6a355db309ccb97a8744675cc3 --- diff --git a/manifest b/manifest index aad62e3fe5..85a244513e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\schanges\sto\stake\sadvantage\sof\sthe\ssqlite3VdbeAppendP4()\smethod. -D 2016-12-08T01:38:24.218 +C Update\sthe\stool/cg_anno.tcl\sscript\sto\sgive\sa\ssummary\sof\scycle\scounts\sby\ncanonical\ssource\sfile\sname. +D 2016-12-08T18:36:19.891 F Makefile.in 7639c6a09da11a9c7c6f2630fc981ee588d1072d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -1453,7 +1453,7 @@ F tool/Replace.cs 02c67258801c2fb5f63231e0ac0f220b4b36ba91 F tool/addopcodes.tcl 10c889c4a65ec6c5604e4a47306fa77ff57ae189 F tool/build-all-msvc.bat 018c1b273458a90c8ba633c6f0c5654cfcb138bf x F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367 -F tool/cg_anno.tcl 692ce4b8693d59e3a3de77ca97f4139ecfa641b0 x +F tool/cg_anno.tcl ac9802cc0f6661beb3bf02dc8792151fdb2ce4a5 x F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2 F tool/dbhash.c a06228aa21ebc4e6ea8daa486601d938499238a5 F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 @@ -1536,7 +1536,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 28883e8f3e92a8015fb5f6c8ae8580833931543d -R 1e20aaec5c4813580d21f8e842d1cbfd +P 83bc5e40af9b20afeed008bf3e2669b7ac9e2dc8 +R 92154a53c8af746c5059d64a2c3e6ba6 U drh -Z d1f3c66819deb29754aa3e44d8d64780 +Z cc8ee367bbd5864c12ba6ee49a8e2fe0 diff --git a/manifest.uuid b/manifest.uuid index e18fdf10e9..b636c3a582 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -83bc5e40af9b20afeed008bf3e2669b7ac9e2dc8 \ No newline at end of file +254a83bf30c15d6a355db309ccb97a8744675cc3 \ No newline at end of file diff --git a/tool/cg_anno.tcl b/tool/cg_anno.tcl index f806c5a5af..0d2bd4dbd5 100755 --- a/tool/cg_anno.tcl +++ b/tool/cg_anno.tcl @@ -2,23 +2,76 @@ # # A wrapper around cg_annotate that sets appropriate command-line options # and rearranges the output so that annotated files occur in a consistent -# sorted order. Used by the run-speed-test.tcl script. +# sorted order. Used by the speed-check.tcl script. # set in [open "|cg_annotate --show=Ir --auto=yes --context=40 $argv" r] set dest ! set out(!) {} +set linenum 0 +set cntlines 0 ;# true to remember cycle counts on each line +set seenSqlite3 0 ;# true if we have seen the sqlite3.c file while {![eof $in]} { set line [string map {\t { }} [gets $in]] if {[regexp {^-- Auto-annotated source: (.*)} $line all name]} { set dest $name - } elseif {[regexp {^-- line \d+ ------} $line]} { + if {[string match */sqlite3.c $dest]} { + set cntlines 1 + set seenSqlite3 1 + } else { + set cntlines 0 + } + } elseif {[regexp {^-- line (\d+) ------} $line all ln]} { set line [lreplace $line 2 2 {#}] + set linenum [expr {$ln-1}] } elseif {[regexp {^The following files chosen for } $line]} { set dest ! } append out($dest) $line\n + if {$cntlines && [regexp { *([0-9,]+) } $line all x]} { + incr linenum + if {[regexp {^ *([0-9,]+) } $line all x]} { + set x [string map {, {}} $x] + set cycles($linenum) $x + } + } } foreach x [lsort [array names out]] { puts $out($x) } + +# If the sqlite3.c file has been seen, then output a summary of the +# cycle counts for each file that went into making up sqlite3.c +# +if {$seenSqlite3} { + close $in + set in [open sqlite3.c] + set linenum 0 + set fn sqlite3.c + set pattern1 {^/\*+ Begin file ([^ ]+) \*} + set pattern2 {^/\*+ Continuing where we left off in ([^ ]+) \*} + while {![eof $in]} { + set line [gets $in] + incr linenum + if {[regexp $pattern1 $line all newfn]} { + set fn $newfn + } elseif {[regexp $pattern2 $line all newfn]} { + set fn $newfn + } elseif {[info exists cycles($linenum)]} { + incr fcycles($fn) $cycles($linenum) + } + } + close $in + puts {**********************************************************************} + set lx {} + set sum 0 + foreach {fn cnt} [array get fcycles] { + lappend lx [list $cnt $fn] + incr sum $cnt + } + puts [format {%20s %14d %8.3f%%} TOTAL $sum 100] + foreach entry [lsort -index 0 -integer -decreasing $lx] { + foreach {cnt fn} $entry break + puts [format {%20s %14d %8.3f%%} $fn $cnt [expr {$cnt*100.0/$sum}]] + } +}