Exemplo n.º 1
0
 public virtual void Test1()
 {
     var stopWatch = new StopWatch();
     stopWatch.Start();
     IDictionary loadedObjects = new Dictionary<object, object>();
     IDictionary modifiedObjects = new Dictionary<object, object>();
     VO.Login.Function f = null;
     OID oid = null;
     for (var i = 0; i < size; i++)
     {
         f = new VO.Login.Function("function " + i);
         oid = OIDFactory.BuildObjectOID(i);
         loadedObjects.Add(oid, f);
         if (i < size / 2)
             modifiedObjects.Add(oid, f);
     }
     var j = 0;
     var nbModified = 0;
     // Now get all modified objects
     var iterator = modifiedObjects.Keys.GetEnumerator();
     while (iterator.MoveNext())
     {
         oid = (OID) iterator.Current;
         var o = modifiedObjects[oid];
         j++;
         nbModified++;
     }
     stopWatch.End();
     Println("time for 2 maps =" + stopWatch.GetDurationInMiliseconds());
     AssertEquals(size / 2, nbModified);
 }
Exemplo n.º 2
0
        public void Test16()
        {
            DeleteBase("valuesA3");

            var t = new StopWatch();
            const int size = 100;
            for (var j = 0; j < 10; j++)
            {
                t.Start();
                using (var odb = Open("valuesA3"))
                {
                    for (var i = 0; i < size; i++)
                    {
                        var tc1 = new TestClass();
                        tc1.SetInt1(45);
                        odb.Store(tc1);
                    }
                }
                t.End();
                Println(" time for insert = " + t.GetDurationInMiliseconds());
            }

            IValues values;
            IObjectValues ov;
            using (var odb = Open("valuesA3"))
            {
                t.Start();
                var valuesQuery = odb.ValuesQuery<TestClass>().Count("nb objects");
                values = valuesQuery.Execute();
                t.End();
                Println(values);
                Println(" time for count = " + t.GetDurationInMiliseconds());
                ov = values.NextValues();
            }

            AssertEquals(size * 10, ov.GetByAlias("nb objects"));
            AssertEquals(1, values.Count);
        }
Exemplo n.º 3
0
 public virtual void Test2()
 {
     var stopWatch = new StopWatch();
     stopWatch.Start();
     IDictionary objects = new Dictionary<object, object>();
     VO.Login.Function f = null;
     OID oid = null;
     ObjectWrapper ow = null;
     var i = 0;
     for (i = 0; i < size; i++)
     {
         f = new VO.Login.Function("function " + i);
         oid = OIDFactory.BuildObjectOID(i);
         objects.Add(oid, new ObjectWrapper(f, false));
         if (i < size / 2)
         {
             ow = (ObjectWrapper) objects[oid];
             ow.SetModified(true);
         }
     }
     i = 0;
     var nbModified = 0;
     // Now get all modified objects
     var iterator = objects.Keys.GetEnumerator();
     while (iterator.MoveNext())
     {
         oid = (OID) iterator.Current;
         ow = (ObjectWrapper) objects[oid];
         if (ow.IsModified())
             nbModified++;
         i++;
     }
     stopWatch.End();
     Println("time for 1 map =" + stopWatch.GetDurationInMiliseconds());
     AssertEquals(size / 2, nbModified);
 }
Exemplo n.º 4
0
        public virtual void TestPerformanceOid()
        {
            var size = 300000;
            var oidMap = new OdbHashMap<OID, string>();

            // OID
            var timeOidMapCreation = new StopWatch();
            timeOidMapCreation.Start();
            // Creates a hashmap with 100000 Longs
            for (var i = 0; i < size; i++)
                oidMap.Add(OIDFactory.BuildObjectOID(i), i.ToString());
            timeOidMapCreation.End();
            var timeOidMapGet = new StopWatch();
            timeOidMapGet.Start();
            // get all map elements
            for (var i = 0; i < size; i++)
                AssertNotNull(oidMap[OIDFactory.BuildObjectOID(i)]);
            timeOidMapGet.End();
            Println(size + " objects : OID Map creation=" + timeOidMapCreation.GetDurationInMiliseconds() + " - get=" +
                    timeOidMapGet.GetDurationInMiliseconds());
        }
Exemplo n.º 5
0
 public virtual void Test1WithoutCommit()
 {
     var stopWatch = new StopWatch();
     stopWatch.Start();
     var size = 10000;
     var size2 = 5000;
     var nbFunctions = 10;
     DeleteBase(FileName);
     var odb = Open(FileName);
     var f1 = new VO.Login.Function("function 1");
     // Create Objects
     for (var i = 0; i < size; i++)
     {
         var p = new Profile("profile number " + i, f1);
         for (var j = 0; j < nbFunctions; j++)
             p.AddFunction(new VO.Login.Function(" inner function of profile : number " + i + " - " + j));
         var user = new User("user name " + i, "user email " + i, p);
         odb.Store(user);
     }
     Println("created");
     // Updates 10 times the objects
     var query = odb.Query<User>();
     var objects = query.Execute<User>();
     for (var k = 0; k < 10; k++)
     {
         objects.Reset();
         for (var i = 0; i < size2; i++)
         {
             var user = objects.Next();
             user.GetProfile().SetName(user.GetProfile().GetName() + "-updated");
             odb.Store(user);
         }
     }
     Println("updated");
     // Delete the rest of the objects
     for (var i = size2; i < size; i++)
         odb.Delete(objects.Next());
     Println("deleted");
     // Check object count
     var query1 = odb.Query<User>();
     objects = query1.Execute<User>();
     AssertEquals(size2, objects.Count);
     // Check data of the objects
     var a = 0;
     while (objects.HasNext())
     {
         var user = objects.Next();
         AssertEquals("user name " + a, user.GetName());
         AssertEquals("user email " + a, user.GetEmail());
         AssertEquals(
             "profile number " + a +
             "-updated-updated-updated-updated-updated-updated-updated-updated-updated-updated",
             user.GetProfile().GetName());
         a++;
     }
     Println("checked");
     for (var k = 0; k < 10; k++)
     {
         objects.Reset();
         for (var i = 0; i < size2; i++)
         {
             var user = objects.Next();
             user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-");
             odb.Store(user);
         }
     }
     Println("re-updated");
     var query2 = odb.Query<User>();
     objects = query2.Execute<User>();
     var engine = ((global::NDatabase.Odb)odb).GetStorageEngine();
     var uncommited =
         engine.GetSession().GetMetaModel().GetClassInfo(typeof (User).FullName, true).UncommittedZoneInfo;
     CIZoneInfo commited =
         engine.GetSession().GetMetaModel().GetClassInfo(typeof (User).FullName, true).CommitedZoneInfo;
     Println("Before commit : uncommited=" + uncommited);
     Println("Before commit : commited=" + commited);
     a = 0;
     while (objects.HasNext())
     {
         // println("a="+a);
         odb.Delete(objects.Next());
         a++;
     }
     AssertEquals(size2, a);
     var query3 = odb.Query<User>();
     AssertEquals(0, query3.Execute<User>().Count);
     AssertEquals(0, odb.Query<User>().Count());
     Println("deleted");
     odb.Close();
     stopWatch.End();
     Println("Total time 2 = " + stopWatch.GetDurationInMiliseconds());
     if (stopWatch.GetDurationInMiliseconds() > 108438)
         Fail("time is > than " + 108438 + " = " + stopWatch.GetDurationInMiliseconds());
 }
Exemplo n.º 6
0
 public virtual void Test1WithCommit()
 {
     var stopWatch = new StopWatch();
     stopWatch.Start();
     var size = 10000;
     var size2 = 5000;
     var nbFunctions = 2;
     DeleteBase(FileName);
     var odb = Open(FileName);
     var f1 = new VO.Login.Function("function 1");
     // Create Objects
     for (var i = 0; i < size; i++)
     {
         var p = new Profile("profile number " + i, f1);
         for (var j = 0; j < nbFunctions; j++)
             p.AddFunction(new VO.Login.Function(" inner function of profile : number " + i + " - " + j));
         var user = new User("user name " + i, "user email " + i, p);
         odb.Store(user);
         if (i % 100 == 0)
         {
         }
     }
     // println("insert " + i);
     odb.Close();
     Println("created");
     // Updates 10 times the objects
     odb = Open(FileName);
     var query = odb.Query<User>();
     var objects = query.Execute<User>();
     Println("got the object " + objects.Count);
     for (var k = 0; k < 10; k++)
     {
         objects.Reset();
         var start = OdbTime.GetCurrentTimeInMs();
         for (var i = 0; i < size2; i++)
         {
             var user = objects.Next();
             user.GetProfile().SetName(user.GetProfile().GetName() + "-updated");
             odb.Store(user);
             if (i % 100 == 0)
             {
             }
         }
         // println("update " + i + " - " + k);
         Println("Update " + k + " - " + (OdbTime.GetCurrentTimeInMs() - start) + " ms");
     }
     Println("updated");
     // Delete the rest of the objects
     for (var i = size2; i < size; i++)
     {
         odb.Delete(objects.Next());
         if (i % 100 == 0)
             Println("delete " + i);
     }
     Println("deleted");
     odb.Close();
     // Check object count
     odb = Open(FileName);
     var query1 = odb.Query<User>();
     objects = query1.Execute<User>();
     AssertEquals(size2, objects.Count);
     // Check data of the objects
     var a = 0;
     while (objects.HasNext())
     {
         var user = objects.Next();
         AssertEquals("user name " + a, user.GetName());
         AssertEquals("user email " + a, user.GetEmail());
         AssertEquals(
             "profile number " + a +
             "-updated-updated-updated-updated-updated-updated-updated-updated-updated-updated",
             user.GetProfile().GetName());
         a++;
     }
     Println("checked");
     for (var k = 0; k < 10; k++)
     {
         objects.Reset();
         for (var i = 0; i < size2; i++)
         {
             var user = objects.Next();
             user.GetProfile().SetName(user.GetProfile().GetName() + "-updated" + "-");
             odb.Store(user);
         }
     }
     Println("re-updated");
     odb.Close();
     // delete objects
     odb = Open(FileName);
     var query2 = odb.Query<User>();
     objects = query2.Execute<User>();
     a = 0;
     while (objects.HasNext())
     {
         odb.Delete(objects.Next());
         a++;
     }
     AssertEquals(size2, a);
     odb.Close();
     odb = Open(FileName);
     var query3 = odb.Query<User>();
     AssertEquals(0, query3.Execute<User>().Count);
     AssertEquals(0, odb.Query<User>().Count());
     Println("deleted");
     odb.Close();
     stopWatch.End();
     Println("Total time 1 = " + stopWatch.GetDurationInMiliseconds());
     if (stopWatch.GetDurationInMiliseconds() > 90700)
         Fail("time is > than " + 90700 + " = " + stopWatch.GetDurationInMiliseconds());
 }
Exemplo n.º 7
0
 public virtual void Test1WithCommit4()
 {
     var stopWatch = new StopWatch();
     stopWatch.Start();
     DeleteBase(FileName);
     var odb = Open(FileName);
     var f1 = new VO.Login.Function("function1");
     odb.Store(f1);
     var f2 = new VO.Login.Function("function2");
     odb.Store(f2);
     odb.Close();
     odb = Open(FileName);
     var query = odb.Query<VO.Login.Function>();
     var objects = query.Execute<VO.Login.Function>();
     VO.Login.Function f = null;
     Println("got the object " + objects.Count);
     for (var k = 0; k < 2; k++)
     {
         objects.Reset();
         while (objects.HasNext())
         {
             f = objects.Next();
             f.SetName(f.GetName() + "updated-");
             odb.Store(f);
         }
     }
     odb.Close();
     odb = Open(FileName);
     var query1 = odb.Query<VO.Login.Function>();
     objects = query1.Execute<VO.Login.Function>();
     odb.Close();
 }
Exemplo n.º 8
0
 public virtual void Test1WithCommit3()
 {
     var stopWatch = new StopWatch();
     stopWatch.Start();
     DeleteBase(FileName);
     var odb = Open(FileName);
     var f1 = new VO.Login.Function("function 1");
     Println(odb.Query<User>().Count());
     var p = new Profile("profile number 0", f1);
     p.AddFunction(new VO.Login.Function("f1"));
     var user = new User("user name 0", "user email 0", p);
     odb.Store(user);
     var p2 = new Profile("profile number 0", f1);
     p2.AddFunction(new VO.Login.Function("f2"));
     var user2 = new User("user name 0", "user email 0", p2);
     odb.Store(user2);
     odb.Close();
     odb = Open(FileName);
     IObjectSet<User> objectSet = null;
     for (var k = 0; k < 2; k++)
     {
         Console.Out.WriteLine(":" + k);
         var query = odb.Query<User>();
         objectSet = query.Execute<User>();
         while (objectSet.HasNext())
         {
             user = objectSet.Next();
             user.GetProfile().SetName(user.GetProfile().GetName() + "-updated");
             Println(user.GetProfile().GetName());
             odb.Store(user);
         }
     }
     odb.Close();
     odb = Open(FileName);
     var query1 = odb.Query<User>();
     objectSet = query1.Execute<User>();
     AssertEquals(2, objectSet.Count);
     odb.Close();
 }