# -*- tcl -*- # Tcl Benchmark File # # This file contains a number of benchmarks for the 'mime' module. # This allow developers to monitor/gauge/track package performance. # # (c) 2006 Andreas Kupries # We need at least version 8.2 for the package and thus the # benchmarks. if {![package vsatisfies [package provide Tcl] 8.2]} { return } # ### ### ### ######### ######### ######### ########################### ## Setting up the environment ... package forget mime catch {namespace delete ::mime} source [file join [file dirname [info script]] mime.tcl] proc construct_item_with_attachment size { set message_token [mime::initialize -canonical text/plain \ -string "This is a first part."] set attachment_body [string repeat abcd\n [expr {$size / 5}]] set attachment_token [mime::initialize \ -canonical application/octet-stream \ -string $attachment_body] set multi_token [mime::initialize -canonical multipart/mixed \ -parts [list $message_token $attachment_token]] set packaged [mime::buildmessage $multi_token] mime::finalize $multi_token return $packaged } # ### ### ### ######### ######### ######### ########################### ## Benchmarks. foreach sz { 1000 10000 50000 100000 200000 400000 800000 1000000 1500000 2500000 5000000 } { bench -desc "MIME initialize/finalize $sz" -pre { set item [construct_item_with_attachment $sz] } -body { mime::finalize [mime::initialize -string $item] } -iter 1 }