Menu

[r3]: / lib / CompPerf.CVS / tcl_append.perf  Maximize  Restore  History

Download this file

111 lines (85 with data), 2.5 kB

#§
#§  CompPerf - tcl_append.perf
#§
#§  (C) IPN - Ingenieurbuero fuer Praezisionsnumerik
#§
#§  Dipl.-Ing. Andreas Otto
#§  Ulmenstrasse 3
#§  D-34289 Zierenberg
#§  mailto:aotto@t-online.de
#§
#§  Alle Rechte vorbehalten
#§

package require PerfLib

##
## -----------------------------------------------------
## the test-procs
##

proc append-0 {a} {
    for { set I 0 } { $I < 1000 } { incr I } {
        continue
    }
}

proc append-1 {a} {
    for { set I 0 } { $I < 1000 } { incr I } {
        string index "--$a--$I--" 0
    }
}

proc append-2 {a} {
    for { set I 0 } { $I < 1000 } { incr I } {
        append X "--$a--$I--"
    }
}

proc append-3 {var a} {
    for { set I 0 } { $I < 1000 } { incr I } {
        append $var "--$a--$I--$I--$I--$I--$I--$I--"
    }
}

proc append-4 {var a} {
    for { set I 0 } { $I < 1000 } { incr I } {
        append $var "--$a--"
    }
}

proc append-5 {a} {
    for { set I 0 } { $I < 1000 } { incr I } {
        append X "--$a--$I--$I--$I--$I--$I--$I--"
    }
}

proc append-6 {a} {
    for { set I 0 } { $I < 1000 } { incr I } {
        append X "--$a--"
    }
}

proc append-7 {a} {
    for { set I 0 } { $I < 1000 } { incr I } {
        append X -- $a -- $I -- $I -- $I -- $I -- $I -- $I --
    }
}

##
## -----------------------------------------------------
## make the test's
##

set NUM     [ ::PerfLib::Num 100 ]

set TOTAL   [ time {

    ::PerfLib::Register append-0 "for loop"
    ::PerfLib::Run      append-0 [time {append-0 KKK} $NUM]

    ::PerfLib::Register append-1 "dyn string"
    ::PerfLib::Run      append-1 [time {append-1 KKK} $NUM]

    ::PerfLib::Register append-2 "append dyn string to CmpLoc"
    ::PerfLib::Run      append-2 [time {append-2 KKK} $NUM]

    ::PerfLib::Register append-3 "append long dyn string to Var"
    ::PerfLib::Run      append-3 [time {append-3 otto KKK} $NUM]

    ::PerfLib::Register append-4 "append short dyn string to Var"
    ::PerfLib::Run      append-4 [time {append-4 otto KKK} $NUM]

    ::PerfLib::Register append-5 "append long dyn string to CmpLoc"
    ::PerfLib::Run      append-5 [time {append-5 KKK} $NUM]

    ::PerfLib::Register append-6 "append short dyn string to CmpLoc"
    ::PerfLib::Run      append-6 [time {append-6 KKK} $NUM]

    ::PerfLib::Register append-7 "append string's to CmpLoc"
    ::PerfLib::Run      append-7 [time {append-7 KKK} $NUM]

} 1 ]

##
## -----------------------------------------------------
## cleanup
##

::PerfLib::Exit

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.