Subversion Repositories Open64

[/] [regression_test/] [lib/] [parse_timefile.exp] - Blame information for rev 1931

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1931 hjz
#!/usr/bin/expect -f
2
 
3
proc ParseTimefile { filename arg_result } {
4
    upvar $arg_result result
5
    set file [open $filename r]
6
    set historys 3
7
    array set result {}
8
    while { [gets $file line] >= 0 } {
9
        set line [string trim $line]
10
        if { [string length $line] > 0 } {
11
      set words [split $line "="]
12
      if { [llength $words] == 2 } {
13
          set values [split [lindex $words 1] ","]
14
    set res [list]
15
    if { [llength $values] != $historys } {
16
                    for {set i 0} {$i < $historys} {incr i} {
17
            lappend res -1
18
        }
19
    } else {
20
        foreach val $values {
21
            lappend res $val
22
                    }
23
                }
24
          set result([string trim [lindex $words 0]]) $res
25
      } else {
26
          error "Bad format in $filename: $line"
27
 
28
      }
29
  }
30
    }
31
    close $file
32
}
33
 
34
proc UpdateTimefile { filename arg_time_list arg_cur_time } {
35
    upvar $arg_time_list time_list
36
    upvar $arg_cur_time cur_time
37
    set file [open $filename w]
38
    foreach key [lsort -dictionary [array names time_list]] {
39
        puts -nonewline $file "$key = "
40
        set tlist $time_list($key)
41
        foreach time [lrange $tlist 1 [expr [llength $tlist] - 1]] {
42
            puts -nonewline $file "$time, "
43
        }
44
        puts $file $cur_time($key)
45
    }
46
    close $file
47
}
48
 
49
proc GetAverageTime { timelist } {
50
    set total 0
51
    set count 0
52
    foreach time $timelist {
53
        if { $time >= 0 } {
54
            incr count
55
            set total [expr $total + $time]
56
        }
57
    }
58
    if { $count == 0 } {
59
        return -1
60
    } else {
61
        return [expr $total / $count]
62
    }
63
}
64
 
65
proc WriteTimeResult { summary arg_runtimes standardfile } {
66
    global testhome datdir
67
    variable standard
68
    upvar $arg_runtimes runtimes
69
    ParseTimefile "$datdir/$standardfile" standard
70
    puts $summary ""
71
    puts $summary " TIME "
72
    puts $summary "======"
73
    puts $summary "--------------------------------------------------------------"
74
    puts $summary "|        Case        |3 times' Avg.|   Present   |   Ratio   |"
75
    puts $summary "--------------------------------------------------------------"
76
    set products 1
77
    set count 0
78
    foreach key [lsort -dictionary [array names runtimes]] {
79
        set std [GetAverageTime $standard($key)]
80
  set actual $runtimes($key)
81
        puts -nonewline $summary [format "| %18s |" $key]
82
        if { $std >= 0 } {
83
      puts -nonewline $summary [format "  %10.3f |" $std]
84
  } else {
85
      puts -nonewline $summary "      -      |"
86
  }
87
  if { $actual >= 0 } {
88
      puts -nonewline $summary [format "  %10.3f |" $actual]
89
  } else {
90
      puts -nonewline $summary "      -      |"
91
  }
92
  if { $std > 0 && $actual >= 0 } {
93
      set ratio [expr $actual / $std]
94
      puts $summary [format " %8.3f%% |" [expr $ratio * 100]]
95
      set products [expr $ratio * $products]
96
      set count [expr $count + 1]
97
  } else {
98
      puts $summary "     -     |"
99
  }
100
    }
101
 
102
    if { $count > 0 } {
103
        set geoavg [format " %8.3f%% " [expr pow($products, 1.0 / $count) * 100]]
104
    } else {
105
        set geoavg "     -     "
106
    }
107
    puts $summary "--------------------------------------------------------------"
108
    puts $summary "|     GeoAverage     |      -      |      -      |$geoavg|"
109
    puts $summary "--------------------------------------------------------------"
110
    UpdateTimefile "$datdir/$standardfile" standard runtimes
111
}
112