Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2000-10-26
08:34 • Closed ticket [219068ffff]: Expose Tcl_HashStats at the Tcl level plus 4 oth... artifact: 1debf08f7a user: welch
01:10 • New ticket [219068ffff]. artifact: aa008fa95e user: nobody

Expose Tcl_HashStats at the Tcl level

Closed / Fixed219068ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:10:10
OriginalBugID: 4557 RFE
Version: 8.3
SubmitDate: '2000-03-24'
LastModified: '2000-05-08'
Severity: MED
Status: Released
Submitter: ericm
ChangedBy: ericm
OS: All
FixedDate: '2000-05-08'
FixedInVersion: 8.4a1
ClosedDate: '2000-10-25'


Sometimes when I'm trying to do performance tuning on my code it's helpful to see how the hash tables I'm using are populated.  Plus, this is kind of a neat, gee-whiz function.  So, it'd be nice if Tcl_HashStats was accessible from Tcl, via "array statistics":


*** tclVar.c    2000/01/21 03:29:14     1.16

--- tclVar.c    2000/03/28 21:44:21

***************

*** 2861,2870 ****


      enum {ARRAY_ANYMORE, ARRAY_DONESEARCH,  ARRAY_EXISTS, ARRAY_GET,

          ARRAY_NAMES, ARRAY_NEXTELEMENT, ARRAY_SET, ARRAY_SIZE,

!         ARRAY_STARTSEARCH, ARRAY_UNSET}; 

      static char *arrayOptions[] = {

        "anymore", "donesearch", "exists", "get", "names", "nextelement",

!       "set", "size", "startsearch", "unset", (char *) NULL

      };


      Interp *iPtr = (Interp *) interp;

--- 2861,2870 ----


      enum {ARRAY_ANYMORE, ARRAY_DONESEARCH,  ARRAY_EXISTS, ARRAY_GET,

          ARRAY_NAMES, ARRAY_NEXTELEMENT, ARRAY_SET, ARRAY_SIZE,

!         ARRAY_STARTSEARCH, ARRAY_STATISTICS, ARRAY_UNSET}; 

      static char *arrayOptions[] = {

        "anymore", "donesearch", "exists", "get", "names", "nextelement",

!       "set", "size", "startsearch", "statistics", "unset", (char *) NULL

      };


      Interp *iPtr = (Interp *) interp;

***************

*** 3178,3183 ****

--- 3178,3198 ----

            varPtr->searchPtr = searchPtr;

            break;

        }

+ 

+       case ARRAY_STATISTICS: {

+           char *stats;

+           stats = Tcl_HashStats(varPtr->value.tablePtr);

+           if (stats != NULL) {

+               Tcl_SetResult(interp, stats, TCL_VOLATILE);

+               ckfree((void *)stats);

+           } else {

+               Tcl_SetResult(interp, "error reading array statistics",

+                       TCL_STATIC);

+               return TCL_ERROR;

+           }

+           break;

+         }

+ 

        case ARRAY_UNSET: {

            Tcl_HashSearch search;

            Var *varPtr2;


- eric




Good thing for 8.4, but the patch is not fully correct (half missing). 
-- 03/27/2000 hobbs

Whoops -- darn cut-n'-paste.  The above patch is now complete (as far as the C source goes anyway).

- eric

-- 03/28/2000 ericm

Done.

- eric

-- 05/08/2000 ericm
welch Closed ticket [219068ffff]. [History diff]2000-10-26 08:34:07
Log in (anonymous is fine) to add a comment.