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 48 49 50 51 52 53 54 55 56 57 58 59
|
# -*- 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 <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.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
}
|