Tuesday, April 19, 2011

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

 http://persistentdictionary.codeplex.com

{ 2 comments... read them below or Comment }

  1. Nice blog and thanks share with u s.
    Business Dictionary

    ReplyDelete
  2. Hi

    I read this two times.
    I like it so much ,try to keep posting.

    regards

    Business Dictionary

    ReplyDelete

Blogger templates

Withoutbugs. Powered by Blogger.

Category

Technology (70) Business (7) Meta (7) thoughts (5) life (3)

Ads Banner

There was an error in this gadget

Formulir Kontak

Name

Email *

Message *

Followers

WITHOUTbugs.com is the best blog full of Great Ideas, Business, Technology, Life Hacks, Thoughts, M

Views

Topads

Join our Team

Video of the Day

- Copyright © WITHOUTbugs.com is the best blog full of Great Ideas, Business, Technology, Life Hacks, Thoughts, M - WithoutBugs- Powered by Blogger | WithoutBugs -