File: delta.tcl

package info (click to toggle)
tcllib 2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,560 kB
  • sloc: tcl: 306,798; ansic: 14,272; sh: 3,035; xml: 1,766; yacc: 1,157; pascal: 881; makefile: 124; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (42 lines) | stat: -rw-r--r-- 1,023 bytes parent folder | download | duplicates (2)
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
proc main {} {
    lassign $::argv linear binary

    set lin [open $linear r]	; gets $lin	;# open and strip header
    set bin [open $binary r]	; gets $bin	;# ditto

    puts [join {Code Type Char} ,]

    lassign {0 0 0 0} lts lws bts bws
    
    while {![eof $lin] && ![eof $bin]} {
	lassign [split [gets $lin] ,] code ltype lwidth
	lassign [split [gets $bin] ,] code btype bwidth

	if {$code eq {}} continue

	# Assuming that binary is faster, compute how much slower linear is in comparison.

	set td [expr {$ltype/$btype}]
	set wd [expr {$lwidth/$bwidth}]

	# > 1 - Linear slower by that factor
	# = 1 - Same performance
	# < 1 - Linear faster by that factor
	
	puts [join [list $code $td $wd] ,]

	# Sum times for overall assessment
	set lts [expr {$lts + $ltype}]
	set lws [expr {$lws + $lwidth}]
	set bts [expr {$bts + $btype}]
	set bws [expr {$bws + $bwidth}]
    }

    # Overall performance difference
    set td [expr {$lts/$bts}]
    set wd [expr {$lws/$bws}]

    puts [join [list $code $td $wd] ,]
}

main