blob: 1f1929fdaf2f680a44357c1bb130f596399cdb97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/usr/bin/env jimsh
# vim:se syntax=tcl:
# Experimental code coverage for Jim Tcl
set auto_path [linsert $auto_path 0 [file dirname $argv0]/jimlib]
set argv [lassign $argv argv0]
set jtime::fileinfo($argv0) {}
set jtime::last [clock micros]
proc jtime::xtrace {type file line result name arglist} {
variable fileinfo
variable last
set now [clock micros]
if {![exists fileinfo($file)]} {
set info {}
} else {
set info $fileinfo($file)
}
incr info($line) $($now - $last)
set fileinfo($file) $info
set last $now
}
xtrace jtime::xtrace
# Catch exit but not error
set rc [catch -noerror -exit {source $argv0} msg opts]
xtrace
set info $jtime::fileinfo($argv0)
set f [open $argv0]
set n 0
while {[$f gets buf] >= 0} {
incr n
if {[info exists info($n)]} {
set prefix [format "%8d: " $info($n)]
} else {
set b [string trimleft $buf]
if {$b eq "" || [string match "#*" $b] || [string match "\}*" $b]} {
set prefix " -: "
} else {
set prefix " ####: "
}
}
puts "$prefix$buf"
}
|