Re: Indexing techniques for hierarchies

From: James <jraustin1_at_hotmail.com>
Date: 26 Dec 2001 18:13:52 -0800
Message-ID: <a6e74506.0112261813.742ba3be_at_posting.google.com>


The following benchmark deviates from the steps outlined earlier in order to simplify it creation. Also posted at www.xdb1.com/Benchmark/7.asp

XDb required 16 ms to access 10,000 objects and copy their properites to variables starting with the last child. Each object was of a different class and each object was the child of the previous object. Each object had five properties of following data types: int(objId), bool, double, dateTime and string.

This benchmark is similar to the following in a relational database. Create 10,000 tables. Each table has one record. Each record has five fields plus an additional integer field is needed in a relational db to related records. Each record is the child of the record in the previous table. Access each record and copy its five properties to variables starting with the last child.

Below is the C++ code (edited for clarity) used for the benchmark.

void CXDbView::MenuTools_Benchmark_7_click() {
// Get start time
// Create objPkg for Test Class

    pTest = pO_m->InstPkg_add_(pRoot_g,        // Cls
                               pFldrMyData_g,  // Parent
                               _T("Test"));    // Inst name


// Create property pPBool
pPBool = pO_m->InstPkg_add_(pRoot_g, // Cls pFldrMyData_g, // Parent _T("PBool")); // Inst name
// Create property pPDbl
pPDbl = pO_m->InstPkg_add_(pRoot_g, // Cls pFldrMyData_g, // Parent _T("PDbl")); // Inst name
// Create property pPDate
pPDate = pO_m->InstPkg_add_(pRoot_g, // Cls pFldrMyData_g, // Parent _T("PDate")); // Inst name
// Create property pPStr
pPStr = pO_m->InstPkg_add_(pRoot_g, // Cls pFldrMyData_g, // Parent _T("PStr")); // Inst name

// Attach properties to Test Cls and set default values
    pO_m->Prop_childFirst_set_(pTest, pPBool, kObjType_PropertyVirtual_g,

                               _T("True"));
    pO_m->Prop_childFirst_set_(pTest, pPDbl, kObjType_PropertyVirtual_g,
                               _T("1.2345678"));
    pO_m->Prop_childFirst_set_(pTest, pPDate, kObjType_PropertyVirtual_g,
                               _T("1/1/2001 12:00 P"));
    pO_m->Prop_childFirst_set_(pTest, pPStr, kObjType_PropertyVirtual_g,                               

_T("abcdefghijklmnopqrstuvwxyz0123456789"));       

// Create X objects, each an instances and child of previous
    pNew = pTest;
    const int LOOPS = 10000;
    for (int x=1; x < LOOPS; x++){

      pNew = pO_m->Inst_add_(pNew,   // cls
                             pNew);  // parent
      ASSERT(pNew);

    }

// Get start time

    DWORD timeStart = GetTickCount();

// Loop thru all instances starting from last child
    pPBoolX = NULL;
    pPDblX = NULL;
    pPDateX = NULL;
    pPStrX = NULL;

    int id = 0;
    bool bol = false;
    double dbl = 0;
    COleDateTime* dt;
    TCHAR str[kObjTxtLenMax_g+1] = _T("");

    pX = pNew;
    while (pX != pTest){

      // Get pX's props and put in local vars
        // Int
          id = pX->id;

        // Bool
          pPBoolX = pO_m->Prop_get_(pX, pPBool, false);
          bol = pO_m->DataBool_get_(pPBoolX->childFirst->cls);

        // Dbl
          pPDblX = pO_m->Prop_get_(pX, pPDbl, false);
          dbl = pO_m->DataDecimalPrecise_get_(pPDblX->childFirst->cls);

        // Date
          pPDateX = pO_m->Prop_get_(pX, pPDate, false);
          dt = pO_m->DataDateTime_get_(pPDateX->childFirst->cls);

        // Str
          pPStrX = pO_m->Prop_get_(pX, pPStr, false);
          pO_m->Data_getAsStr_(pPStrX->childFirst->cls, str);

      // Move to parent
        pX = pX->parent_();

    }

// Get end time

    DWORD timeEnd = GetTickCount();

// Calc time elapsed

    DWORD timeElapsed = timeEnd - timeStart;

// Async flush memory to disk

    pDb_m->File_save_();

// Display results

    CString sResults;
    sResults.Format(_T("Benchmark 7\n

                    Accessed props of %d hierarchal objs in %d
msec."),
                    LOOPS, timeElapsed);

    MessageBox(sResults);
} Received on Thu Dec 27 2001 - 03:13:52 CET

Original text of this message