Ignore:
Timestamp:
Nov 22, 2002, 3:20:01 PM (23 years ago)
Author:
darin
Message:
  • prepare to reimplement KJS::List; move to its own file, add statistics
  • kjs/function_object.cpp: (FunctionProtoFuncImp::call): Use new copyTail() function rather than copy() and removeFirst().
  • kjs/identifier.cpp: Add statistics, off by default.
  • kjs/property_map.cpp: Add statistics, off by default.
  • kjs/list.cpp: Added. Moved code here. To be rewritten.
  • kjs/list.h: Added. Moved interface here. To be rewritten.
  • kjs/types.cpp: Removed.
  • kjs/types.h: Now just an empty header that includes other headers.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/property_map.cpp

    r2821 r2834  
    2727
    2828#define DO_CONSISTENCY_CHECK 0
    29 
    30 // At the time I added this switch, the optimization still gave a 1.5% performance boost so I couldn't remove it.
     29#define DUMP_STATISTICS 0
    3130#define USE_SINGLE_ENTRY 1
     31
     32// At the time I added USE_SINGLE_ENTRY, the optimization still gave a 1.5% performance boost so I couldn't remove it.
    3233
    3334#if !DO_CONSISTENCY_CHECK
     
    3637
    3738namespace KJS {
     39
     40#if DUMP_STATISTICS
     41
     42static int numProbes;
     43static int numCollisions;
     44
     45struct PropertyMapStatisticsExitLogger { ~PropertyMapStatisticsExitLogger(); };
     46
     47static PropertyMapStatisticsExitLogger logger;
     48
     49PropertyMapStatisticsExitLogger::~PropertyMapStatisticsExitLogger()
     50{
     51    printf("\nKJS::PropertyMap statistics\n\n");
     52    printf("%d probes\n", numProbes);
     53    printf("%d collisions (%.1f%%)\n", numCollisions, 100.0 * numCollisions / numProbes);
     54}
     55
     56#endif
    3857
    3958struct PropertyMapHashTable
     
    116135   
    117136    int i = hash(rep);
     137#if DUMP_STATISTICS
     138    ++numProbes;
     139    numCollisions += _table->entries[i].key && _table->entries[i].key != rep;
     140#endif
    118141    while (UString::Rep *key = _table->entries[i].key) {
    119142        if (rep == key) {
     
    140163   
    141164    int i = hash(rep);
     165#if DUMP_STATISTICS
     166    ++numProbes;
     167    numCollisions += _table->entries[i].key && _table->entries[i].key != rep;
     168#endif
    142169    while (UString::Rep *key = _table->entries[i].key) {
    143170        if (rep == key)
     
    177204   
    178205    int i = hash(rep);
     206#if DUMP_STATISTICS
     207    ++numProbes;
     208    numCollisions += _table->entries[i].key && _table->entries[i].key != rep;
     209#endif
    179210    while (UString::Rep *key = _table->entries[i].key) {
    180211        if (rep == key) {
     
    202233
    203234    int i = hash(key);
     235#if DUMP_STATISTICS
     236    ++numProbes;
     237    numCollisions += _table->entries[i].key && _table->entries[i].key != key;
     238#endif
    204239    while (_table->entries[i].key)
    205240        i = (i + 1) & _table->sizeMask;
     
    263298    // Find the thing to remove.
    264299    int i = hash(rep);
     300#if DUMP_STATISTICS
     301    ++numProbes;
     302    numCollisions += _table->entries[i].key && _table->entries[i].key != rep;
     303#endif
    265304    while ((key = _table->entries[i].key)) {
    266305        if (rep == key)
Note: See TracChangeset for help on using the changeset viewer.