Overview
| Artifact ID: | 70ec3427b23fe1c2d782812ca293ede36fb38c19 |
|---|---|
| Ticket: | 3069593fffffffffffffffffffffffffffffffff
Performance gap between [string equal] and [string compare] |
| User & Date: | ferrieux on 2010-09-17 22:54:49 |
Changes
- assignee changed to: "dkf"
- cmimetype changed to: "text/plain"
- comment changed to:
The "streq" and "strcmp" instructions could benefit from a bit of unification (as suggested by a comment in tclExecute.c). For example, [string compare] has very efficient special cases for ByteArray and String operands, that [string equal] lacks. As a consequence, a naive test of equality on big byte arrays with [string equal] is ~7 times slower than the less obvious [string compare], despite the fact that the latter produces a more elaborate result (three-valued instead of binary): Source this: set z [open /dev/zero r] fconfigure $z -translation binary set b1 [read $z 1000000] set b2 [read $z 1000000] set y 1 Then interactively: % time {string compare $b1 $b2} 1000 301.596 microseconds per iteration % time {string compare $b1 $b2} 1000 299.637 microseconds per iteration % time {string compare $b1 $b2} 1000 298.203 microseconds per iteration % ::tcl::unsupported::representation $b1 value is a bytearray with a refcount of 2, object pointer at 0x9b55e50, internal representation 0xb69ae010:0x9b56fc0, no string representation. % ::tcl::unsupported::representation $b2 value is a bytearray with a refcount of 2, object pointer at 0x9b56e58, internal representation 0xb68ac010:0x9b55e50, no string representation. % time {string equal $b1 $b2} 1000 2159.225 microseconds per iteration % time {string equal $b1 $b2} 1000 2128.354 microseconds per iteration % time {string equal $b1 $b2} 1000 2129.929 microseconds per iteration % ::tcl::unsupported::representation $b1 value is a bytearray with a refcount of 2, object pointer at 0x9b55e50, internal representation 0xb69ae010:0x9b56fc0, no string representation. % ::tcl::unsupported::representation $b2 value is a bytearray with a refcount of 2, object pointer at 0x9b56e58, internal representation 0xb68ac010:0x9b55e50, no string representation. - foundin changed to: "None"
- is_private changed to: "0"
- priority changed to: "7 High"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "ferrieux"
- subsystem changed to: "18. Commands M-Z"
- title changed to:
Performance gap between [string equal] and [string compare]
- type changed to: "Bug"