tclcompiler Code
Brought to you by:
aotto1968
#§ #§ CompPerf - ot_list.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 MkList {} { global List for { set A 0 } { $A < 100 } { incr A } { lappend List $A } } MkList proc ListProc { List } { return [ lindex $List 0 ] } proc ListProc2 { LList } { return [ lindex [ lindex $LList 0 ] 0 ] } proc list-1.1 {} { return [ ListProc [ list 1 2 3 4 5 6 7 8 9 ] ] } proc list-1.1b {} { return [ ListProc [ list ] ] } proc list-1.2 {} { global List set X [list] foreach [ list A B ] $List { lappend X $A $B } } proc list-1.3 {} { global List set X [list] foreach {A B} $List { lappend X $A $B } } proc list-1.5 {} { return [ ListProc2 [ list [ list 1 2 ] [ list 3 4 ] [ list 5 6 ] ] ] } proc list-1.6 {} { return [ ListProc2 { { 1 2 } { 3 4 } { 5 6 } } ] } ## ## ----------------------------------------------------- ## make the test's ## set NUM [ ::PerfLib::Num 5000 ] set TOTAL [ time { ::PerfLib::Register list-1.1 "proc with LIST argument" ::PerfLib::Run list-1.1 [time {list-1.1} $NUM] ::PerfLib::Register list-1.1b "proc with empty LIST argument" ::PerfLib::Run list-1.1b [time {list-1.1b} $NUM] ::PerfLib::Register list-1.2 "foreach with \"list\" command (no compiled locals)" ::PerfLib::Run list-1.2 [time {list-1.2} $NUM] ::PerfLib::Register list-1.3 "foreach without \"list\" command" ::PerfLib::Run list-1.3 [time {list-1.3} $NUM] ::PerfLib::Register list-1.5 "proc with \"list\" LList argument" ::PerfLib::Run list-1.5 [time {list-1.5} $NUM] ::PerfLib::Register list-1.6 "proc with LList argument" ::PerfLib::Run list-1.6 [time {list-1.6} $NUM] } 1 ] ## ## ----------------------------------------------------- ## cleanup ## ::PerfLib::Exit