Key Features:

A data structure implementation similar to Dictionary in .NET.

- Writes objects to file system to preserve the memory
- Hold keys/locations in memory
- Retrieves any object by passing key in less than five milliseconds

Output, with 10000 inserts/updates/deletes:

image

Memory profiling:

image

   1: using (CPersistentDictionary lst = new CPersistentDictionary(@"C:\persist.kkhan"))
<!--CRLF-->
   2: {
<!--CRLF-->
   3:     Stopwatch timer = new Stopwatch();
<!--CRLF-->
   4:  
<!--CRLF-->
   5:     //1. Insert/update items
<!--CRLF-->
   6:  
<!--CRLF-->
   7:     int threshold = 10000;
<!--CRLF-->
   8:     timer.Start();
<!--CRLF-->
   9:     for (int i = 0; i < threshold; i++)
<!--CRLF-->
  10:     {
<!--CRLF-->
  11:         lst.Add("Counter" + i.ToString(), i.ToString());
<!--CRLF-->
  12:     }
<!--CRLF-->
  13:     timer.Stop();
<!--CRLF-->
  14:     Console.WriteLine("Items processed(add):{0}", threshold);
<!--CRLF-->
  15:     Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);
<!--CRLF-->
  16:  
<!--CRLF-->
  17:  
<!--CRLF-->
  18:     //2. Read items
<!--CRLF-->
  19:     timer.Start();
<!--CRLF-->
  20:     for (int i = 0; i < threshold; i++)
<!--CRLF-->
  21:     {
<!--CRLF-->
  22:         var o = lst["Counter" + i.ToString()];
<!--CRLF-->
  23:     }
<!--CRLF-->
  24:     timer.Stop();
<!--CRLF-->
  25:     Console.WriteLine("Items processed(read):{0}", threshold);
<!--CRLF-->
  26:     Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);
<!--CRLF-->
  27:  
<!--CRLF-->
  28:  
<!--CRLF-->
  29:     //3. Remove items
<!--CRLF-->
  30:     timer.Start();
<!--CRLF-->
  31:     for (int i = 0; i < threshold; i++)
<!--CRLF-->
  32:     {
<!--CRLF-->
  33:         lst.Remove("Counter" + i.ToString());
<!--CRLF-->
  34:     }
<!--CRLF-->
  35:     timer.Stop();
<!--CRLF-->
  36:     Console.WriteLine("Items processed(Remove):{0}", threshold);
<!--CRLF-->
  37:     Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);
<!--CRLF-->
  38:  
<!--CRLF-->
  39:  
<!--CRLF-->
  40:  
<!--CRLF-->
  41:     Console.ReadKey();
<!--CRLF-->
  42: }
<!--CRLF-->

 

TODO:

- Requires update in .Remove() method, proper cleanup is required.

Last edited Apr 19, 2011 at 7:46 AM by kkhan, version 3

Comments

No comments yet.