Project Description
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

http://izlooite.blogspot.com/2011/04/persistent-dictionary.html

Output, with 10000 inserts/updates/deletes:

Memory profiling:

Usage:

using (CPersistentMap lst = new CPersistentMap())
{
    Stopwatch timer = new Stopwatch();

    //1. Insert/update items
                
    int threshold = 100;
    timer.Start();
    for (int i = 0; i < threshold; i++)
    {
        lst.Add("Counter" + i.ToString(), i.ToString());
    }
    timer.Stop();
    Console.WriteLine("Items processed(add):{0}", threshold);
    Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);


    //2. Read items
    timer.Start();
    for (int i = 0; i < threshold; i++)
    {
        var o = lst["Counter" + i.ToString()];
    }
    timer.Stop();
    Console.WriteLine("Items processed(read):{0}", threshold);
    Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);


    //3. Remove items
    timer.Start();
    for (int i = 0; i < threshold; i++)
    {
        lst.Remove("Counter" + i.ToString());
    }
    timer.Stop();
    Console.WriteLine("Items processed(Remove):{0}", threshold);
    Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);


    Console.WriteLine("Time taken to read items:{0}", 1);
    Console.WriteLine("Time elapsed in (ms):{0}  ({1} secs)", timer.ElapsedMilliseconds, TimeSpan.FromMilliseconds(timer.ElapsedMilliseconds).Seconds);

}

http://izlooite.blogspot.com/2011/04/persistent-dictionary.html

Last edited Feb 23, 2012 at 9:04 PM by kkhan, version 5