This project is read-only.

Comparison of different object databases


For the details about comparison sample, please take a look on NDatabase basic sample

Simple steps:

Time 1 Size 1 Time 2 Size 2 Time 3 Time 4 Size 4 Time 5
NDatabase 1.0.1 190 ms 19432 253 ms 20585 259 ms 274 ms 20585 277 ms
NDatabase 1.0.2 181 ms 19432 239 ms 20585 244 ms 257 ms 20585 259 ms
NDatabase 2.2 173 ms 19432 231 ms 20585 238 ms 253 ms 20585 257 ms
NDatabase 3.0 188 ms 19432 244 ms 20585 253 ms 270 ms 20585 276 ms
NeoDatis.net 199 ms 19440 260 ms 20593 269 ms 282 ms 20593 285 ms
db4o 445 ms 2588 607 ms 3448 706 ms 822 ms 3825 895 ms
  • Size in bytes

Summary times:
perf1.png

Description:
  • Step 1 - after storing two initial warriors (objects).
  • Step 2 - after retrieving warriors (two objects), assigning items to them and storing them back into db.
  • Step 3 - after retrieving items and displaying them by interface.
  • Step 4 - after displaying and then removing warriors (two objects) from db.
  • Step 5 - after retrieving empty warrior list.

Performance step:
Insert time Insert size Update time Update size Delete time Delete size
NDatabase 1.0.1 772 ms 2159889 2841 ms 6399463 3799 ms 6399463
NDatabase 1.0.2 769 ms 2159889 2826 ms 6399463 3756 ms 6399463
NDatabase 1.0.3 731 ms 2159889 2769 ms 6399463 3632 ms 6399463
NDatabase 3.0 780 ms 2159889 3070 ms 6399463 4119 ms 6399463
NeoDatis.net 967 ms 2159897 4062 ms 6399471 6146 ms 6399471
db4o 711 ms 1113983 2760 ms 3251568 4144 ms 3251568


Summary times:
perf2.png

Description:
  • insert - insert of 10000 warrior objects.
  • update - query and update of 10000 warriors, inserting new 20000 items.
  • delete - remove of 10000 warriors.

For the details, please check below information or take a look on the source code - tutorial directory.

NDatabase code


Step 1

var warrior1 = new Warrior("Warrior 1");
var warrior2 = new Warrior("Warrior 2");

using (var odb2 = OdbFactory.Open(DBName))
{
    odb2.Store(warrior1);
    odb2.Store(warrior2);
}

Step 2

var sword1 = new Sword(5);
var sword2 = new Sword(3);

var field1 = new Field(3);
var field2 = new Field(5);


using (var odb = OdbFactory.OpenLast())
{
    IList<Warrior> warriors = odb.Query<Warrior>().Execute<Warrior>().ToList();

    warriors[0].RightHand = sword1;
    warriors[0].LeftHand = field1;

    warriors[1].RightHand = sword2;
    warriors[1].LeftHand = field2;

    odb.Store(warriors[0]);
    odb.Store(warriors[1]);
}

Step 3

using (var odb1 = OdbFactory.OpenLast())
{
    IList<IItem> items = odb1.Query<IItem>().Execute<IItem>().ToList();

    foreach (var item in items)
        Console.WriteLine(item);
}

Step 4

using (var odb1 = OdbFactory.OpenLast())
{
    IList<Warrior> warriors = odb1.Query<Warrior>().Execute<Warrior>().ToList();

    foreach (var warrior in warriors)
        Console.WriteLine(warrior);

    Console.WriteLine("Remove warriors");

    odb1.Delete(warriors[0]);
    odb1.Delete(warriors[1]);
}

Step 5

int count;
using (var odb = OdbFactory.OpenLast())
    count = odb.Query<Warrior>().Execute<Warrior>().Count;

Console.WriteLine("Warriors count: {0}", count);

NeoDatis.Net code


Step 1

var warrior1 = new Warrior("Warrior 1");
var warrior2 = new Warrior("Warrior 2");

var odb = ODBFactory.Open(DBName);
odb.Store(warrior1);
odb.Store(warrior2);
odb.Close();

Step 2

var sword1 = new Sword(5);
var sword2 = new Sword(3);

var field1 = new Field(3);
var field2 = new Field(5);


var odb = ODBFactory.Open(DBName);

IList<Warrior> warriors1 = odb.GetObjects<Warrior>().ToList();

warriors1[0].RightHand = sword1;
warriors1[0].LeftHand = field1;

warriors1[1].RightHand = sword2;
warriors1[1].LeftHand = field2;

odb.Store(warriors1[0]);
odb.Store(warriors1[1]);
odb.Close();

Step 3

var odb1 = ODBFactory.Open(DBName);
var query = new CriteriaQuery(typeof (IItem));
query.SetPolymorphic(true);

IList<IItem> items = odb1.GetObjects<IItem>(query).ToList();

foreach (var item in items)
    Console.WriteLine(item);

odb1.Close();

Step 4

var odb1 = ODBFactory.Open(DBName);

IList<Warrior> warriors = odb1.GetObjects<Warrior>().ToList();

foreach (var warrior in warriors)
    Console.WriteLine(warrior);

Console.WriteLine("Remove warriors");

odb1.Delete(warriors[0]);
odb1.Delete(warriors[1]);
odb1.Close();

Step 5

var odb = ODBFactory.Open(DBName);
var count = odb.GetObjects<Warrior>().Count;
odb.Close();

Console.WriteLine("Warriors count: {0}", count);

Issues

  • it contains a bug and you cannot instantiate class without default constructor and with validation in ctor. Changed implementation of warrior there.
  • miss of IDisposable interface on a main db interface (you need to close manually)

db4o code


Step 1

var warrior1 = new Warrior("Warrior 1");
var warrior2 = new Warrior("Warrior 2");

using (var odb = Db4oEmbedded.OpenFile(DBName))
{
    odb.Store(warrior1);
    odb.Store(warrior2);
}

Step 2

var sword1 = new Sword(5);
var sword2 = new Sword(3);

var field1 = new Field(3);
var field2 = new Field(5);


using (var odb = Db4oEmbedded.OpenFile(DBName))
{
    IList<Warrior> warriors = odb.Query<Warrior>().ToList();

    warriors[0].RightHand = sword1;
    warriors[0].LeftHand = field1;

    warriors[1].RightHand = sword2;
    warriors[1].LeftHand = field2;

    odb.Store(warriors[0]);
    odb.Store(warriors[1]);
}

Step 3

using (var odb1 = Db4oEmbedded.OpenFile(DBName))
{
    IList<IItem> items = odb1.Query<IItem>().ToList();

    foreach (var item in items)
        Console.WriteLine(item);
}

Step 4

using (var odb1 = Db4oEmbedded.OpenFile(DBName))
{
    IList<Warrior> warriors = odb1.Query<Warrior>().ToList();

    foreach (var warrior in warriors)
        Console.WriteLine(warrior);

    Console.WriteLine("Remove warriors");

    odb1.Delete(warriors[0]);
    odb1.Delete(warriors[1]);
}

Step 5

int count;
using (var odb = Db4oEmbedded.OpenFile(DBName))
    count = odb.Query<Warrior>().Count;

Console.WriteLine("Warriors count: {0}", count);

Basic Sample Set code


public static class BasicSampleSet
{
    public static void Process(string dbName, string projectName, Action step1, 
                    Action step2, Action step3, Action step4, Action step5)
    {
        if (File.Exists(dbName))
            File.Delete(dbName);

        Console.WriteLine("NDatabase Tutorial - basic for {0}\n", projectName);
        Console.WriteLine("DB Name: {0}", dbName);
        Console.WriteLine("\n\nSTEP1\n");
        var stopwatch = new Stopwatch();

        Console.WriteLine("Preparing two warriors with empty equipment");
        stopwatch.Start();

        step1();

        stopwatch.Stop();
        Display(stopwatch, "after storing two initial warriors");

        Console.WriteLine("\tFile size: {0} bytes", new FileInfo(dbName).Length);

        Console.WriteLine("\n\nSTEP2\n");
        Console.WriteLine("Retriving warriors, add equipment, update warriors.");

        stopwatch.Start();

        step2();

        stopwatch.Stop();
        Display(stopwatch, 
            "after retrieving warriors, assigning equipment and storing back into db");

        Console.WriteLine("\tFile size: {0} bytes", new FileInfo(dbName).Length);

        Console.WriteLine("\n\nSTEP3\n");
        Console.WriteLine("Retrieve and display stored items.");
        stopwatch.Start();

        step3();

        stopwatch.Stop();
        Display(stopwatch, "after displaying and then removing warriors");

        Console.WriteLine("\n\nSTEP4\n");
        Console.WriteLine("Retrieve and display stored warriors, then remove them.");
        stopwatch.Start();

        step4();

        stopwatch.Stop();
        Display(stopwatch, "after displaying and then removing warriors");

        Console.WriteLine("\tFile size: {0} bytes", new FileInfo(dbName).Length);

        Console.WriteLine("\n\nSTEP5\n");
        Console.WriteLine("Get warriors count from db");
        stopwatch.Start();

        step5();

        stopwatch.Stop();
        Display(stopwatch, "after getting empty warrior list");
    }

    private static void Display(Stopwatch stopwatch, string action)
    {
        Console.WriteLine("Action: {0}, \n\tEllapsed: {1} ms.", action,
                         stopwatch.ElapsedMilliseconds);
    }
}

Last edited Dec 30, 2012 at 10:16 AM by jacek, version 47

Comments

No comments yet.