aboutsummaryrefslogtreecommitdiff
path: root/tools/benchtable.tcl
blob: e853f612bd9b7e97278a98ce065f999bdf6f4851 (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
#!/usr/bin/env tclsh
#
# Tabulate the output of Jim's bench.tcl -batch
#
# Copyright (C) 2005 Pat Thoyts <patthoyts@users.sourceforge.net>
#
# $Id: benchtable.tcl,v 1.2 2005/03/10 10:03:32 antirez Exp $

proc main {filename} {
    set versions {}
    array set bench {}
    set f [open $filename r]
    while {![eof $f]} {
        gets $f data
        lappend versions [lindex $data 0]
        set results [lindex $data 1]
        foreach {title time} $results {
            lappend bench($title) $time
        }
    }
    close $f

    puts "Jim benchmarks - time in milliseconds"
    puts -nonewline [string repeat " " 21]
    foreach v $versions {
        puts -nonewline [format "% 6s " $v]
    }
    puts ""

    foreach test [array names bench] {
        puts -nonewline "[format {% 20s} $test] "
        foreach v $bench($test) {
            if {$v eq "F"} {
                puts -nonewline "     F "
            } else {
                puts -nonewline [format "% 6d " [expr {$v / 1000}]]
            }
        }
        puts ""
    }
}

if {!$tcl_interactive} {
    set r [catch {eval [linsert $argv 0 main]} res]
    puts $res
    exit $r
}