Menu

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

Download this file

91 lines (68 with data), 1.7 kB

#§
#§  CompPerf - tcl_unset.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 unset-1.1 {} {
  ## Unsetting an existing variable
    set i 0
    unset i
}

proc unset-1.2 {} {
  ## Catching invalid unset
    set i 0
    catch {unset j}
}


proc unset-1.3 {} {
  ## Catching valid unset
    set i 0
    catch {unset i}
}


proc unset-1.4 {} {
  ## Testing existing variable before unset
    set i 0
    if {[info exists i]} {
        unset i
    }
}

proc unset-1.5 {} {
  ## Testing non-existent variable before unset
    set i 0
    if {[info exists j]} {
        unset j
    }
}


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

set NUM     [ ::PerfLib::Num 1000 ]

set TOTAL   [ time {

    ::PerfLib::Register unset-1.1 "Unsetting an existing variable"
    ::PerfLib::Run      unset-1.1 [time {unset-1.1} $NUM]

    ::PerfLib::Register unset-1.2 "Catching invalid unset"
    ::PerfLib::Run      unset-1.2 [time {unset-1.2} $NUM]

    ::PerfLib::Register unset-1.3 "Catching valid unset"
    ::PerfLib::Run      unset-1.3 [time {unset-1.3} $NUM]

    ::PerfLib::Register unset-1.4 "Testing existing variable before unset"
    ::PerfLib::Run      unset-1.4 [time {unset-1.4} $NUM]

    ::PerfLib::Register unset-1.5 "Testing non-existent variable before unset"
    ::PerfLib::Run      unset-1.5 [time {unset-1.5} $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.