Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 755e5e0ae2f63fe39cacce929bef71c11da3ab35
Ticket: 1990276fffffffffffffffffffffffffffffffff
Surprising differences in variable access speed.
User & Date: patthoyts on 2008-06-10 23:10:41
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    I'm testing out adding a state option to the binary encode functions to make it simpler to write channels that use these functions. The -state option takes a variable name. In the C code we therefore get a bytearray object passed in via the objv array and may also get another object passed via name.
    I get a 10x faster calling time using the pass-by-name.
    
    % proc t1 {} {variable data; binary encode hex $data}
    % proc t2 {} {variable data; binary encode hex -state data ""}
    % set data [binary format @102400] ; string length [t1]
    204800
    % set data [binary format @102400] ; string length [t2]
    204800
    % set data [binary format @102400] ; time {t1} 10
    1755.9 microseconds per iteration
    % set data [binary format @102400] ; time {t2} 10
    218.6 microseconds per iteration
    
    !!!!!
    
    The C function accesses these Tcl_Obj's using:
        data = input = Tcl_GetByteArrayFromObj(objv[objc-1], &count);
        if (stateObj) {
    data = state = Tcl_GetByteArrayFromObj(stateObj, &state_count);
    count += state_count;
        }
    and then I move the 'data' pointer along the state data first then the input data. So the C code is identical for each calling method.
    
    You can see the full function at http://paste.tclers.tk/973
    
    
    
    
  4. foundin changed to: "obsolete: 8.6a0"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "patthoyts"
  10. subsystem changed to: "07. Variables"
  11. title changed to: "Surprising differences in variable access speed."
  12. type changed to: "Bug"