bench_wcsv.tcl

Go to the documentation of this file.
00001 /*  bench_wtext.tcl --*/
00002 /* */
00003 /*  Management of benchmarks, formatted text.*/
00004 /* */
00005 /*  Copyright (c) 2005 by Andreas Kupries <andreas_kupries@users.sourceforge.net>*/
00006 /*  library derived from runbench.tcl application (C) Jeff Hobbs.*/
00007 /* */
00008 /*  See the file "license.terms" for information on usage and redistribution*/
00009 /*  of this file, and for a DISCLAIMER OF ALL WARRANTIES.*/
00010 /*  */
00011 /*  RCS: @(#) $Id: bench_wcsv.tcl,v 1.4 2007/01/21 23:29:06 andreas_kupries Exp $*/
00012 
00013 /*  ### ### ### ######### ######### ######### ###########################*/
00014 /*  Requisites - Packages and namespace for the commands and data.*/
00015 
00016 package require Tcl 8.2
00017 package require csv
00018 
00019 namespace ::bench::out {}
00020 
00021 /*  ### ### ### ######### ######### ######### ###########################*/
00022 /*  Public API - Benchmark execution*/
00023 
00024 /*  ### ### ### ######### ######### ######### ###########################*/
00025 /*  Public API - Result formatting.*/
00026 
00027 /*  ::bench::out::csv --*/
00028 /* */
00029 /*  Format the result of a benchmark run.*/
00030 /*  Style: CSV*/
00031 /* */
00032 /*  Arguments:*/
00033 /*  DATA dict*/
00034 /* */
00035 /*  Results:*/
00036 /*  String containing the formatted DATA.*/
00037 
00038 ret  ::bench::out::csv (type data) {
00039     array set DATA $data
00040     set CSV {}
00041 
00042     # 1st record:              #shells
00043     # 2nd record to #shells+1: Interpreter data (id, version, path)
00044     # #shells+2 to end:        Benchmark data (id,desc,result1,...,result#shells)
00045 
00046     # --- --- ----
00047     # #interpreters used
00048 
00049     set ipkeys [array names DATA interp*]
00050     lappend CSV [csv::join [list [llength $ipkeys]]]
00051 
00052     # --- --- ----
00053     # Table 1: Interpreter information.
00054 
00055     set n 1
00056     set iplist {}
00057     foreach key [lsort -dict $ipkeys] {
00058     set ip [lindex $key 1]
00059     lappend CSV [csv::join [list $n $DATA($key) $ip]]
00060     set DATA($key) $n
00061     incr n
00062     lappend iplist $ip
00063     }
00064 
00065     # --- --- ----
00066     # Table 2: Benchmark information
00067 
00068     set dlist {}
00069     foreach key [lsort -dict -index 1 [array names DATA desc*]] {
00070     lappend dlist [lindex $key 1]
00071     }
00072 
00073     set n 1
00074     foreach desc $dlist { 
00075     set record {}
00076     lappend record $n
00077     lappend record $desc
00078     foreach ip $iplist {
00079         if {[catch {
00080         lappend record $DATA([list usec $desc $ip])
00081         }]} {
00082         lappend record {}
00083         }
00084     }
00085     lappend CSV [csv::join $record]
00086     incr n
00087     }
00088 
00089     return [join $CSV \n]
00090 }
00091 
00092 /*  ### ### ### ######### ######### ######### ###########################*/
00093 /*  Internal commands*/
00094 
00095 /*  ### ### ### ######### ######### ######### ###########################*/
00096 /*  Initialize internal data structures.*/
00097 
00098 /*  ### ### ### ######### ######### ######### ###########################*/
00099 /*  Ready to run*/
00100 
00101 package provide bench::out::csv 0.1.2
00102 

Generated on 21 Sep 2010 for Gui by  doxygen 1.6.1