# perf_conv

> ## Directory

> > eXtremeDB_rt/samples/perf_conv

> ## Description

> > Demonstrates measuring XtremeDB/rt performance for basic operations

> ## Used API

> > Class_hkey_find(), Class_tkey_search(), Class_from_cursor(), mco_db_free_pages(), mco_db_total_pages(), mco_db_page_size(), sample_msec()

> ## Code snippet

> >         printf("\n\tTree search:\n\t");

> >           start_time = sample_msec();

> >           rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &t);
> >           if ( MCO_S_OK == rc ) {

> >             rc = Record_tkey_index_cursor(t, &c);
> >             if ( MCO_S_OK == rc ) {

> >               for (i = 0; i &lt; nRecords* 2; i++)
> >               {
> >                 key = i;
> >                 rc = Record_tkey_search(t, &c, MCO_EQ, key);

> >                 if (i % 2 == 0)
> >                 {
> >                   Record obj;
> >                   mco_uint4 ui4;

> >                   if ( MCO_S_OK == rc ) {
> >                     rc = Record_from_cursor(t, &c, &obj);
> >                     if ( MCO_S_OK == rc ) {
> >                       rc = Record_key_get(&obj, &ui4);

> >                     .....

> >                 if (i % (nRecords / 10) == 0)
> >                 {
> >                   printf(".");
> >                 }
> >               }
> >             }
> >             mco_trans_commit(t);
> >           }
> >           printf("\n\t%d searches: %d milliseconds (%d microsecs/search)\n", (nRecords * 2),
> >                   (int)(sample_msec() - start_time), (int)(((sample_msec() - start_time)* 1000) / (nRecords * 2)));

> ## What to expect as an output

> >         First N objects are inserted into a class, a hash index is created
> >         	on insertion, then used for searches.  Then a tree index is built
> >         	and searches are performed by key, then sequentially.
> >         	Finally, the tree index is removed and all objects are deleted
> >         	one-by-one.  Each insert and delete is done in a separate
> >         	transaction, so that the commit time is included in measurements.

> >         Memory usage 202496 from 1516288 bytes
> >         	Insert:
> >         	..........
> >         	2000 objects: 4 milliseconds,(2 microsecs/object)
> >         Memory usage 291584 from 1516288 bytes

> >         	Hash search:
> >         	....................Memory usage 291584 from 1516288 bytes

> >         	4000 searches: 0 milliseconds (0 microsecs/search)

> >         	Tree search:
> >         	....................
> >         	4000 searches: 2 milliseconds (0 microsecs/search)
> >         Memory usage 291584 from 1516288 bytes

> >         	Sequential:
> >         	..........
> >         	2000 searches: 1 milliseconds (0 microsecs/search)
> >         Memory usage 291584 from 1516288 bytes

> >         	Search/delete:
> >         	....................
> >         	4000 objects: 6 milliseconds (1 microsecs/object)
> >         Memory usage 202496 from 1516288 bytes