Example #1
0
        private static void MeasurePerformance()
        {
            var program = new Program();

            const int queries = 5000;
            const int runs = 10;

            for(int x = 0; x<runs; x++)
            {
                Console.WriteLine("Pass {0}", x + 1);

                program.Measure((int) MeasurementType.SingleSessionSingleTransaction, db =>
                {
                    using(ISession session = new SessionImpl(db))
                    {
                        using(ITransaction transaction = session.BeginTransaction())
                        {
                            for(int i = 0; i<queries; i++)
                            {
                                session.Get<FormText>(i);
                            }
                            transaction.Commit();
                        }
                    }
                });

                program.Measure((int) MeasurementType.SingleSessionMultipleTransactions, db =>
                {
                    using(ISession session = new SessionImpl(db))
                    {
                        for(int i = 0; i<queries; i++)
                        {
                            using(ITransaction transaction = session.BeginTransaction())
                            {
                                session.Get<FormText>(i);
                                transaction.Commit();
                            }
                        }
                    }
                });

                program.Measure((int) MeasurementType.MultipleSessionsMultipleTransactions, db =>
                {
                    for(int i = 0; i<queries; i++)
                    {
                        using(ISession session = new SessionImpl(db))
                        {
                            using(ITransaction transaction = session.BeginTransaction())
                            {
                                session.Get<FormText>(i);
                                transaction.Commit();
                            }
                        }
                    }
                });

                program.Measure((int) MeasurementType.MultipleSessionsNoTransactions, db =>
                {
                    for(int i = 0; i<queries; i++)
                    {
                        using(ISession session = new SessionImpl(db))
                        {
                            session.Get<FormText>(i);
                        }
                    }
                });
                Console.WriteLine();
            }

            Console.WriteLine();
            program.DisplayStats();
        }