? patch
Index: bench.tcl
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/bench/bench.tcl,v
retrieving revision 1.9
diff -u -r1.9 bench.tcl
--- bench.tcl	28 Mar 2007 17:49:44 -0000	1.9
+++ bench.tcl	20 Aug 2007 22:11:48 -0000
@@ -47,6 +47,7 @@
     # -match  <pattern>    only run tests matching this pattern
     # -rmatch <pattern>    only run tests matching this pattern
     # -iters  <num>        default 1000, max#iterations for any benchmark
+    # -pkgdirs <dir list>  defaults to no auto_path manipulation
 
     # interps - dict (path -> version)
     # files   - list (of files)
@@ -59,6 +60,8 @@
     set match   {}   ; # Do not exclude benchmarks based on glob pattern
     set rmatch  {}   ; # Do not exclude benchmarks based on regex pattern
     set iters   1000 ; # Limit #iterations for any benchmark
+    set pkgdirs {{}} ; # List of dirs to put in front of auto_path in the
+                       # bench interpreters.
 
     while {[string match "-*" [set opt [lindex $args 0]]]} {
 	set val [lindex $args 1]
@@ -87,6 +90,14 @@
 		}
 		set iters   [lindex $args 1]
 	    }
+            -pkgdirs {
+                if {[catch {set pkgdirslength [llength $val]}]} {
+                    return -code error "Expected list, got \"$val\""
+                }
+                if {$pkgdirslength} {
+                    set pkgdirs $val
+                }
+            }
 	    default {
 		return -code error "Unknown option \"$opt\", should -errors, -threads, -match, -rmatch, or -iters"
 	    }
@@ -97,72 +108,81 @@
 	return -code error "wrong\#args, should be: ?options? interp files"
     }
     foreach {interps files} $args break
-
+    
     # Run the benchmarks .....................................
 
     array set DATA {}
 
     foreach {ip ver} $interps {
-	log::info "Benchmark $ver $ip"
-
-	set DATA([list interp ${ip}]) $ver
-
-	set cmd [list $ip [file join $self libbench.tcl] \
-		-match   $match   \
-		-rmatch  $rmatch  \
-		-iters   $iters   \
-		-interp  $ip      \
-		-errors  $errors  \
-		-threads $threads \
-		]
-
-	# Determine elapsed time per file, logged.
-	set start [clock seconds]
-
-	array set tmp {}
-
-	if {$threads} {
-	    if {[catch {
-		eval exec $cmd $files
-	    } output]} {
-		if {$errors} {
-		    error $::errorInfo
-		}
-	    } else {
-		array set tmp $output
-	    }
-	} else {
-	    foreach file $files {
-		log::info [file tail $file]
-		if {[catch {
-		    eval exec [linsert $cmd end $file]
-		} output]} {
-		    if {$errors} {
-			error $::errorInfo
-		    } else {
-			continue
-		    }
-		} else {
-		    array set tmp $output
-		}
-	    }
-	}
-
-	catch {unset tmp(Sourcing)}
-	catch {unset tmp(__THREADED)}
-
-	foreach desc [array names tmp] {
-	    set DATA([list desc $desc]) {}
-	    set DATA([list usec $desc $ip]) $tmp($desc)
-	}
-
-	unset tmp
-	set elapsed [expr {[clock seconds] - $start}]
-
-	set hour [expr {$elapsed / 3600}]
-	set min  [expr {$elapsed / 60}]
-	set sec  [expr {$elapsed % 60}]
-	log::info " [format %.2d:%.2d:%.2d $hour $min $sec] elapsed"
+        foreach pkgdir $pkgdirs {
+            if {[llength $pkgdir]} {
+                log::info "Benchmark $ver ($pkgdir) $ip"
+                set idstr "$ip ($pkgdir)"
+            } else {
+                log::info "Benchmark $ver $ip"
+                set idstr "$ip"
+            }
+
+            set DATA([list interp $idstr]) $ver
+
+            set cmd [list $ip [file join $self libbench.tcl] \
+                         -match   $match   \
+                         -rmatch  $rmatch  \
+                         -iters   $iters   \
+                         -interp  $ip      \
+                         -errors  $errors  \
+                         -threads $threads \
+                         -pkgdirs $pkgdir  \
+                        ]
+
+            # Determine elapsed time per file, logged.
+            set start [clock seconds]
+            
+            array set tmp {}
+            
+            if {$threads} {
+                if {[catch {
+                    eval exec $cmd $files
+                } output]} {
+                    if {$errors} {
+                        error $::errorInfo
+                    }
+                } else {
+                    array set tmp $output
+                }
+            } else {
+                foreach file $files {
+                    log::info [file tail $file]
+                    if {[catch {
+                        eval exec [linsert $cmd end $file]
+                    } output]} {
+                        if {$errors} {
+                            error $::errorInfo
+                        } else {
+                            continue
+                        }
+                    } else {
+                        array set tmp $output
+                    }
+                }
+            }
+            
+            catch {unset tmp(Sourcing)}
+            catch {unset tmp(__THREADED)}
+            
+            foreach desc [array names tmp] {
+                set DATA([list desc $desc]) {}
+                set DATA([list usec $desc $idstr]) $tmp($desc)
+            }
+            
+            unset tmp
+            set elapsed [expr {[clock seconds] - $start}]
+            
+            set hour [expr {$elapsed / 3600}]
+            set min  [expr {$elapsed / 60}]
+            set sec  [expr {$elapsed % 60}]
+            log::info " [format %.2d:%.2d:%.2d $hour $min $sec] elapsed"
+        }
     }
 
     # Benchmark data ... Structure, dict (key -> value)
Index: libbench.tcl
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/bench/libbench.tcl,v
retrieving revision 1.2
diff -u -r1.2 libbench.tcl
--- libbench.tcl	23 Jan 2007 03:21:35 -0000	1.2
+++ libbench.tcl	20 Aug 2007 22:11:49 -0000
@@ -350,6 +350,7 @@
 	FILES		{}
 	ITERS		1000
 	THREADS		0
+        PKGDIRS         {}
 	EXIT		"[info exists tk_version]"
 } {
     if {![info exists BENCH($var)]} {
@@ -369,6 +370,7 @@
 	    -mat*	{ set BENCH(MATCH)   [lindex $argv 1] }
 	    -iter*	{ set BENCH(ITERS)   [lindex $argv 1] }
 	    -thr*	{ set BENCH(THREADS) [lindex $argv 1] }
+            -pkg*       { set BENCH(PKGDIRS) [lindex $argv 1] }
 	    default {
 		foreach arg $argv {
 		    if {![file exists $arg]} { usage }
@@ -381,6 +383,10 @@
     }
 }
 
+if {[llength $BENCH(PKGDIRS)]} {
+    set auto_path [linsert $auto_path 0 $BENCH(PKGDIRS)]
+}
+
 if {$BENCH(THREADS)} {
     # We have to be able to load threads if we want to use threads, and
     # we don't want to create more threads than we have files.
