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()); }
static void Main(string[] args) { var stopwatch = new StopWatch(); stopwatch.Start(); for (var i = 0; i < 2; i++) { Thread.Sleep(1); } stopwatch.End(); Console.WriteLine("TimeSapn : {0}", stopwatch.GetTimeSpan()); }
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); }
protected virtual T ExecuteScalar <T>(DbCommand dbCommand) { object result = null; StopWatch stopWatch = new StopWatch(); try { dbCommand.CommandTimeout = timeout; Logger.Info("ExecuteScalar, StoreProcedureName=" + dbCommand.CommandText + ", Params={" + GetParams(dbCommand) + "}"); result = database.ExecuteScalar(dbCommand); return(ConversionUtil.To <T>(result)); } finally { stopWatch.End(); Logger.Info("ExecuteScalar Complete, result=" + ConversionUtil.To <string>(result) + " elapsed=" + stopWatch.ElapsedMs()); } }
protected virtual DataSet ExecuteDataSet(DbCommand dbCommand) { DataSet dataSet = null; StopWatch stopWatch = new StopWatch(); try { dbCommand.CommandTimeout = timeout; dataSet = database.ExecuteDataSet(dbCommand); Logger.Info("ExecuteDataSet, StoreProcedureName=" + dbCommand.CommandText + ", Params={" + GetParams(dbCommand) + "}, Dataset Summary=" + GetDataSetSummary(dataSet)); return(dataSet); } finally { stopWatch.End(); Logger.Info("ExecuteNonQuery Complete, elapsed=" + stopWatch.ElapsedMs()); } }
protected virtual int ExecuteNonQuery(DbCommand dbCommand) { int result = 0; StopWatch stopWatch = new StopWatch(); try { dbCommand.CommandTimeout = timeout; Logger.Info("ExecuteNonQuery, StoreProcedureName=" + dbCommand.CommandText + ", Params={" + GetParams(dbCommand) + "}"); result = database.ExecuteNonQuery(dbCommand); return(result); } finally { stopWatch.End(); Logger.Info("ExecuteNonQuery Complete, result=" + result + ", elapsed=" + stopWatch.ElapsedMs()); } }
protected virtual int ExecuteBatchSPCall(DbCommand dbCommand, DataSet dataSet) { int result = 0; StopWatch stopWatch = new StopWatch(); try { dbCommand.CommandTimeout = timeout; Logger.Info("ExecuteBatchUpdate, StoreProcedureName=" + dbCommand.CommandText); result = database.UpdateDataSet(dataSet, BATCHTABLENAME, dbCommand, null, null, UpdateBehavior.Standard); return(result); } finally { stopWatch.End(); Logger.Info("ExecuteBatchUpdate Complete, result=" + result + " ,elapsed=" + stopWatch.ElapsedMs() + " ms"); } }
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); }
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); }
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()); } }
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()); } }