Exemplo n.º 1
0
        public void CommitSubTransaction_Relations()
        {
            Console.WriteLine("Expected average duration of CommitSubTransaction_Relations on reference system: ~150 ms");

            using (ClientTransaction.CreateRootTransaction().CreateSubTransaction().EnterDiscardingScope())
            {
                ClassWithRelationProperties[] objects = TestDomainObjectMother.PrepareDatabaseObjectsWithRelationProperties(TestSetSize);

                Assert.That(ClientTransaction.Current.HasChanged(), Is.False);

                // warm up
                ChangeObjectsWithRelations(objects);
                ClientTransaction.Current.Commit();

                var stopwatch = new Stopwatch();

                for (int i = 0; i < TestRepititions; i++)
                {
                    ChangeObjectsWithRelations(objects);
                    stopwatch.Start();
                    ClientTransaction.Current.Commit();
                    stopwatch.Stop();
                }

                Assert.That(ClientTransaction.Current.HasChanged(), Is.False);

                double averageMilliSeconds = stopwatch.Elapsed.TotalMilliseconds / TestRepititions;
                Console.WriteLine(
                    "CommitSubTransaction_Relations (executed {0} x Commit ({2} objects - total {3} objects in CTx)): Average duration: {1} ms",
                    TestRepititions,
                    averageMilliSeconds.ToString("n"),
                    objects.Length,
                    ClientTransaction.Current.EnlistedDomainObjectCount);
            }
        }
        public void AskChanged()
        {
            Console.WriteLine("Expected average duration of HasRelationChangedTest on reference system: ~8 ms");

            using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope())
            {
                var  objects = TestDomainObjectMother.PrepareDatabaseObjectsWithRelationProperties(TestSetSize);
                bool changed = ClientTransaction.Current.HasChanged();

                Assert.That(changed, Is.False);

                var stopwatch = new Stopwatch();
                stopwatch.Start();
                for (int i = 0; i < TestRepititions; i++)
                {
                    changed ^= ClientTransaction.Current.HasChanged();
                }
                stopwatch.Stop();

                Console.WriteLine(changed);

                double averageMilliSeconds = stopwatch.Elapsed.TotalMilliseconds / TestRepititions;
                Console.WriteLine(
                    "HasRelationChangedTest (executed {0} x ClientTransaction.Current.HasChanged ({2} objects - total {3} objects in CTx)): Average duration: {1} ms",
                    TestRepititions,
                    averageMilliSeconds.ToString("n"),
                    objects.Length,
                    ClientTransaction.Current.EnlistedDomainObjectCount);
            }
        }
Exemplo n.º 3
0
        public void CommitTransactionToDatabase_NewProperties()
        {
            Console.WriteLine("Expected average duration of CommitTransactionToDatabase_NewProperties on reference system: ~3.5 ms");

            using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope())
            {
                TestDomainObjectMother.PrepareDatabaseObjectsWithValueProperties(TestSetSize);
                ClientTransaction.Current.Commit();
            }

            var stopwatch = new Stopwatch();

            for (int i = 0; i < TestRepititions; i++)
            {
                using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope())
                {
                    TestDomainObjectMother.PrepareDatabaseObjectsWithValueProperties(TestSetSize);
                    stopwatch.Start();
                    ClientTransaction.Current.Commit();
                    stopwatch.Stop();
                }
            }

            double averageMilliSeconds = stopwatch.Elapsed.TotalMilliseconds / TestRepititions;

            Console.WriteLine(
                "CommitTransactionToDatabase_NewProperties (executed {0} x Commit ({2} objects)): Average duration: {1} ms",
                TestRepititions,
                averageMilliSeconds.ToString("n"),
                TestSetSize);
        }