/ Check-in [254a83bf]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update the tool/cg_anno.tcl script to give a summary of cycle counts by canonical source file name.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 254a83bf30c15d6a355db309ccb97a8744675cc3
User & Date: drh 2016-12-08 18:36:19
Context
2016-12-08
19:04
Fix a minor error in the cg_anno.tcl script causing the cycles-per-file counts to be miscomputed. check-in: b26df26e user: drh tags: trunk
18:36
Update the tool/cg_anno.tcl script to give a summary of cycle counts by canonical source file name. check-in: 254a83bf user: drh tags: trunk
01:38
More changes to take advantage of the sqlite3VdbeAppendP4() method. check-in: 83bc5e40 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tool/cg_anno.tcl.

     1      1   #!/usr/bin/tclsh
     2      2   #
     3      3   # A wrapper around cg_annotate that sets appropriate command-line options
     4      4   # and rearranges the output so that annotated files occur in a consistent
     5         -# sorted order.  Used by the run-speed-test.tcl script.
            5  +# sorted order.  Used by the speed-check.tcl script.
     6      6   #
     7      7   
     8      8   set in [open "|cg_annotate --show=Ir --auto=yes --context=40 $argv" r]
     9      9   set dest !
    10     10   set out(!) {}
           11  +set linenum 0
           12  +set cntlines 0      ;# true to remember cycle counts on each line
           13  +set seenSqlite3 0   ;# true if we have seen the sqlite3.c file
    11     14   while {![eof $in]} {
    12     15     set line [string map {\t {        }} [gets $in]]
    13     16     if {[regexp {^-- Auto-annotated source: (.*)} $line all name]} {
    14     17       set dest $name
    15         -  } elseif {[regexp {^-- line \d+ ------} $line]} {
           18  +    if {[string match */sqlite3.c $dest]} {
           19  +      set cntlines 1
           20  +      set seenSqlite3 1
           21  +    } else {
           22  +      set cntlines 0
           23  +    }
           24  +  } elseif {[regexp {^-- line (\d+) ------} $line all ln]} {
    16     25       set line [lreplace $line 2 2 {#}]
           26  +    set linenum [expr {$ln-1}]
    17     27     } elseif {[regexp {^The following files chosen for } $line]} {
    18     28       set dest !
    19     29     }
    20     30     append out($dest) $line\n
           31  +  if {$cntlines && [regexp { *([0-9,]+) } $line all x]} {
           32  +    incr linenum
           33  +    if {[regexp {^ *([0-9,]+) } $line all x]} {
           34  +      set x [string map {, {}} $x]
           35  +      set cycles($linenum) $x
           36  +    }
           37  +  }
    21     38   }
    22     39   foreach x [lsort [array names out]] {
    23     40     puts $out($x)
    24     41   }
           42  +
           43  +# If the sqlite3.c file has been seen, then output a summary of the
           44  +# cycle counts for each file that went into making up sqlite3.c
           45  +#
           46  +if {$seenSqlite3} {
           47  +  close $in
           48  +  set in [open sqlite3.c]
           49  +  set linenum 0
           50  +  set fn sqlite3.c
           51  +  set pattern1 {^/\*+ Begin file ([^ ]+) \*}
           52  +  set pattern2 {^/\*+ Continuing where we left off in ([^ ]+) \*}
           53  +  while {![eof $in]} {
           54  +    set line [gets $in]
           55  +    incr linenum
           56  +    if {[regexp $pattern1 $line all newfn]} {
           57  +      set fn $newfn
           58  +    } elseif {[regexp $pattern2 $line all newfn]} {
           59  +      set fn $newfn
           60  +    } elseif {[info exists cycles($linenum)]} {
           61  +      incr fcycles($fn) $cycles($linenum)
           62  +    }
           63  +  }
           64  +  close $in
           65  +  puts {**********************************************************************}
           66  +  set lx {}
           67  +  set sum 0
           68  +  foreach {fn cnt} [array get fcycles] {
           69  +    lappend lx [list $cnt $fn]
           70  +    incr sum $cnt
           71  +  }
           72  +  puts [format {%20s %14d  %8.3f%%} TOTAL $sum 100]
           73  +  foreach entry [lsort -index 0 -integer -decreasing $lx] {
           74  +    foreach {cnt fn} $entry break
           75  +    puts [format {%20s %14d  %8.3f%%} $fn $cnt [expr {$cnt*100.0/$sum}]]
           76  +  }
           77  +}