Exemplo n.º 1
0
        public void AdoNetOnly()
        {
            for (int n = 2; n < 4000; n *= 2)
            {
                Simple[] simples = new Simple[n];
                for (int i = 0; i < n; i++)
                {
                    simples[i] = new Simple();
                    simples[i].Init();
                    simples[i].Count = i;
                    simples[i].Id = i;
                }

                //Now do timings
                Timer timer = new Timer();

                IDbConnection _connection = sqlMap.DataSource.DbProvider.CreateConnection();
                _connection.ConnectionString = sqlMap.DataSource.ConnectionString;

                _connection.Open();

                timer.Start();
                DirectAdoNet(_connection, simples, n, "j1");
                timer.Stop();
                double adonet = 1000000 * (timer.Duration / (double)n);
                _connection.Close();

                _connection.Open();
                timer.Start();
                DirectAdoNet(_connection, simples, n, "j2");
                timer.Stop();
                adonet += 1000000 * (timer.Duration / (double)n);
                _connection.Close();

                _connection.Open();
                timer.Start();
                DirectAdoNet(_connection, simples, n, "j2");
                timer.Stop();
                adonet += 1000000 * (timer.Duration / (double)n);
                _connection.Close();

                System.Console.Out.WriteLine("Objects: " + n + " Direct ADO.NET: " + adonet.ToString("F3"));
            }
            System.GC.Collect();
        }
Exemplo n.º 2
0
        public void IbatisOnly()
        {
            for (int n = 2; n < 4000; n *= 2)
            {
                Simple[] simples = new Simple[n];
                object[] ids = new object[n];
                for (int i = 0; i < n; i++)
                {
                    simples[i] = new Simple();
                    simples[i].Init();
                    simples[i].Count = i;
                    simples[i].Id = i;
                }

                //Now do timings
                Timer timer = new Timer();
                GC.Collect();
                GC.WaitForPendingFinalizers();

                sqlMap.OpenConnection();
                timer.Start();
                Ibatis(simples, n, "h1");
                timer.Stop();
                double ibatis = 1000000 * (timer.Duration / (double)n);
                sqlMap.CloseConnection();

                sqlMap.OpenConnection();
                timer.Start();
                Ibatis(simples, n, "h2");
                timer.Stop();
                ibatis += 1000000 * (timer.Duration / (double)n);
                sqlMap.CloseConnection();

                sqlMap.OpenConnection();
                timer.Start();
                Ibatis(simples, n, "h2");
                timer.Stop();
                ibatis += 1000000 * (timer.Duration / (double)n);
                sqlMap.CloseConnection();

                System.Console.WriteLine("Objects: " + n + " - iBATIS DataMapper: " + ibatis.ToString("F3"));
            }
            System.GC.Collect();
        }
Exemplo n.º 3
0
        public void Simultaneous()
        {
            double ibatis = 0;
            double adonet = 0;

            IDbConnection _connection = sqlMap.DataSource.DbProvider.CreateConnection();
            _connection.ConnectionString = sqlMap.DataSource.ConnectionString;

            for (int n = 2; n < 4000; n *= 2)
            {
                Simple[] simples = new Simple[n];
                for (int i = 0; i < n; i++)
                {
                    simples[i] = new Simple();
                    simples[i].Init();
                    simples[i].Count = i;
                    simples[i].Id = i;
                }

                sqlMap.OpenConnection();
                Ibatis(simples, n, "h0");
                sqlMap.CloseConnection();

                _connection.Open();
                DirectAdoNet(_connection, simples, n, "j0");
                _connection.Close();

                sqlMap.OpenConnection();
                Ibatis(simples, n, "h0");
                sqlMap.CloseConnection();

                _connection.Open();
                DirectAdoNet(_connection, simples, n, "j0");
                _connection.Close();

                //Now do timings
                Timer timer = new Timer();

                GC.Collect();
                GC.WaitForPendingFinalizers();

                sqlMap.OpenConnection();
                timer.Start();
                Ibatis(simples, n, "h1");
                timer.Stop();
                ibatis = 1000000 * (timer.Duration / (double)n);
                sqlMap.CloseConnection();

                _connection.Open();
                timer.Start();
                DirectAdoNet(_connection, simples, n, "j1");
                timer.Stop();
                adonet = 1000000 * (timer.Duration / (double)n);
                _connection.Close();

                sqlMap.OpenConnection();
                timer.Start();
                Ibatis(simples, n, "h2");
                timer.Stop();
                ibatis += 1000000 * (timer.Duration / (double)n);
                sqlMap.CloseConnection();

                _connection.Open();
                timer.Start();
                DirectAdoNet(_connection, simples, n, "j2");
                timer.Stop();
                adonet += 1000000 * (timer.Duration / (double)n);
                _connection.Close();

                sqlMap.OpenConnection();
                timer.Start();
                Ibatis(simples, n, "h2");
                timer.Stop();
                ibatis += 1000000 * (timer.Duration / (double)n);
                sqlMap.CloseConnection();

                _connection.Open();
                timer.Start();
                DirectAdoNet(_connection, simples, n, "j2");
                timer.Stop();
                adonet += 1000000 * (timer.Duration / (double)n);
                _connection.Close();
                System.Console.Out.WriteLine("Objects " + n + " iBATIS DataMapper : " + ibatis.ToString("F3") + " / Direct ADO.NET: " + adonet.ToString("F3") + " Ratio: " + ((ibatis / adonet)).ToString("F3"));
            }

            System.GC.Collect();
        }
Exemplo n.º 4
0
        public void Many()
        {
            double ibatis = 0;
            double adonet = 0;

            for (int n = 0; n < 5; n++)
            {
                Simple[] simples = new Simple[n];
                for (int i = 0; i < n; i++)
                {
                    simples[i] = new Simple();
                    simples[i].Init();
                    simples[i].Count = i;
                    simples[i].Id = i;
                }

                sqlMap.OpenConnection();
                Ibatis(simples, n, "h0");
                sqlMap.CloseConnection();

                IDbConnection _connection = sqlMap.DataSource.DbProvider.CreateConnection();
                _connection.ConnectionString = sqlMap.DataSource.ConnectionString;

                _connection.Open();
                DirectAdoNet(_connection, simples, n, "j0");
                _connection.Close();

                sqlMap.OpenConnection();
                Ibatis(simples, n, "h0");
                sqlMap.CloseConnection();

                _connection.Open();
                DirectAdoNet(_connection, simples, n, "j0");
                _connection.Close();

                // now do timings

                int loops = 30;
                Timer timer = new Timer();

                for (int runIndex = 1; runIndex < 4; runIndex++)
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    timer.Start();
                    for (int i = 0; i < loops; i++)
                    {
                        sqlMap.OpenConnection();
                        Ibatis(simples, n, "h" + runIndex.ToString());
                         sqlMap.CloseConnection();
                    }
                    timer.Stop();
                    ibatis += 1000000 * (timer.Duration / (double)loops);

                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    timer.Start();
                    for (int i = 0; i < loops; i++)
                    {
                        _connection.Open();
                        DirectAdoNet(_connection, simples, n, "j" + runIndex.ToString());
                        _connection.Close();
                    }
                    timer.Stop();
                    adonet += 1000000 * (timer.Duration / (double)loops);

                }
            }
            System.Console.Out.WriteLine("iBatis DataMapper : " + ibatis.ToString("F3") + " / Direct ADO.NET: " + adonet.ToString("F3") + " Ratio: " + ((ibatis / adonet)).ToString("F3"));

            System.GC.Collect();
        }