# -*- tcl -*-
# Tcl Benchmark File
#
# This file contains a number of benchmarks for the 'csv' module.
# This allow developers to monitor/gauge/track package performance.
#
# (c) 2005 Andreas Kupries <andreas_kupries@users.sourceforge.net>

# We need at least version 8.2 for the package and thus the
# benchmarks.

if {![package vsatisfies [package provide Tcl] 8.3]} {
    return
}

# ### ### ### ######### ######### ######### ###########################
## Setting up the environment ...

package forget csv
catch {namespace delete ::csv}
source [file join [file dirname [info script]] csv.tcl]

# ### ### ### ######### ######### ######### ###########################
## Benchmarks.

foreach n {1 10 100 1000 10000} {
    bench -desc "CSV join $n" -pre {
	set list [split [string repeat " " $n] ""]
    } -body {
	csv::join $list
    } -post {
	unset list
    }

    bench -desc "CSV split $n" -pre {
	set str [string repeat , $n]
    } -body {
	csv::split $str
    } -post {
	unset str
    }
}

# ### ### ### ######### ######### ######### ###########################
## Complete
