Overview
| Artifact ID: | 24c49b1216456be54afc9c5ba2e04938e38b4985 |
|---|---|
| Ticket: | 3163961fffffffffffffffffffffffffffffffff
TIP 405: mapeach implementation with bytecoding |
| User & Date: | twylite on 2012-08-02 19:32:29 |
Changes
- icomment:
# Performance tests # Tcl = 32-bit tclsh86t.exe from trunk [19174445] with branches bug-3545363 # and td-mapeach merged in, built with MSVC10, OPTS=threads # Platform = Intel64 (AMD64) i5 @ 2.67Ghz running Windows 7 (64-bit) set d [lsearch -all [lrepeat 1000000 x] x] ; llength $d lindex $d 1000 ;# ensure list rep time { set accum {} foreach {k v} $::d { lappend accum [expr { $k * $v }] } puts [tcl::mathop::+ {*}$accum] ;# 166666416666500000 } # 750919 microseconds per iteration (foreach) time { puts [tcl::mathop::+ {*}[mapeach {k v} $::d { expr { $k * $v } }]] ;# 166666416666500000 } # 616432 microseconds per iteration (mapeach) time { apply {{} { set accum {} foreach {k v} $::d { lappend accum [expr { $k * $v }] } puts [tcl::mathop::+ {*}$accum] ;# 166666416666500000 }} } # 382724 microseconds per iteration (apply foreach) time { apply {{} { puts [tcl::mathop::+ {*}[mapeach {k v} $::d { expr { $k * $v } }]] ;# 166666416666500000 }} } # 382829 microseconds per iteration (apply mapeach) dict get $d 1000 ;# ensure dict rep time { set accum {} dict for {k v} $::d { lappend accum [expr { $k * $v }] } puts [tcl::mathop::+ {*}$accum] ;# 166666416666500000 } # 739547 microseconds per iteration (dict for) time { puts [tcl::mathop::+ {*}[dict map {k v} $::d { expr { $k * $v } }]] ;# 166666416666500000 } # 621000 microseconds per iteration (dict map) time { apply {{} { set accum {} dict for {k v} $::d { lappend accum [expr { $k * $v }] } puts [tcl::mathop::+ {*}$accum] ;# 166666416666500000 }} } # 357713 microseconds per iteration (apply dict for) time { apply {{} { puts [tcl::mathop::+ {*}[dict map {k v} $::d { expr { $k * $v } }]] ;# 166666416666500000 }} } # 360457 microseconds per iteration (apply dict map) RANK: # 357713 microseconds per iteration (apply dict for) # 360457 microseconds per iteration (apply dict map) # 382724 microseconds per iteration (apply foreach) # 382829 microseconds per iteration (apply mapeach) # 616432 microseconds per iteration (mapeach) # 621000 microseconds per iteration (dict map) # 739547 microseconds per iteration (dict for) # 750919 microseconds per iteration (foreach) - login: "twylite"
- mimetype: "text/plain"
- username: "twylite"