コード例 #1
0
        public void WithCustomProjectionAndSmallResultSet()
        {
            var linqHelper = CreateLinqPerformanceTestHelper(() => from c in QueryFactory.CreateLinqQuery <Company>() select new { c.ID, c.Name });

            var message = "Custom projection query with small (200) result set ";

            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM)", linqHelper.GenerateQueryModel);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL)", linqHelper.GenerateQueryModelAndSQL);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL+IQ)", linqHelper.GenerateQueryModelAndSQLAndIQuery);
            //PerformanceTestHelper.TimeAndOutput (2000, message + "(QM+SQL+IQ+Execute)", linqHelper.GenerateAndExecuteQueryDBOnly);
            PerformanceTestHelper.TimeAndOutput(1000, message + "(QM+SQL+IQ+Execute+re-store)", linqHelper.GenerateAndExecuteQuery);
        }
コード例 #2
0
        public void WithLargeResultSet()
        {
            Func <IQueryable <Person> > queryGenerator = () => (from p in QueryFactory.CreateLinqQuery <Person> () select p);
            var linqHelper = new LinqPerformanceTestHelper <Person> (queryGenerator);

            var message = "Simple query with large (2000) result set ";

            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM)", linqHelper.GenerateQueryModel);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL)", linqHelper.GenerateQueryModelAndSQL);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL+IQ)", linqHelper.GenerateQueryModelAndSQLAndIQuery);
            PerformanceTestHelper.TimeAndOutput(100, message + "(QM+SQL+IQ+Execute)", linqHelper.GenerateAndExecuteQueryDBOnly);
            PerformanceTestHelper.TimeAndOutput(100, message + "(QM+SQL+IQ+Execute+re-store)", linqHelper.GenerateAndExecuteQuery);
        }
コード例 #3
0
        public void WithComplexQuery_GroupBy()
        {
            var query = (from p in QueryFactory.CreateLinqQuery <Person> () group p by p.FirstName into gp from grp in gp select grp);
            Func <IQueryable <Person> > queryGenerator = () => (query);
            var linqHelper = new LinqPerformanceTestHelper <Person> (queryGenerator);

            var message = "Complex query with group by ";

            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM)", linqHelper.GenerateQueryModel);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL)", linqHelper.GenerateQueryModelAndSQL);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL+IQ)", linqHelper.GenerateQueryModelAndSQLAndIQuery);
            PerformanceTestHelper.TimeAndOutput(1000, message + "(QM+SQL+IQ+Execute)", linqHelper.GenerateAndExecuteQueryDBOnly);
            PerformanceTestHelper.TimeAndOutput(500, message + "(QM+SQL+IQ+Execute+re-store)", linqHelper.GenerateAndExecuteQuery);
        }
コード例 #4
0
        public void WithComplexQuery_SubqueriesInSecondFromClauseAndMultiplyOrderByClauses()
        {
            var query = (from c in QueryFactory.CreateLinqQuery <Client> ()
                         from p in (from sp in QueryFactory.CreateLinqQuery <Person>() where sp.Client == c orderby sp.FirstName orderby sp.LastName select sp)
                         from co in (from sco in QueryFactory.CreateLinqQuery <Company>() where sco.Client == c orderby sco.Name select sco)
                         select p).Distinct();
            Func <IQueryable <Person> > queryGenerator = () => (query);
            var linqHelper = new LinqPerformanceTestHelper <Person> (
                queryGenerator);

            var message = "Complex query with subqueries in second from clause and multiply order by clauses ";

            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM)", linqHelper.GenerateQueryModel);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL)", linqHelper.GenerateQueryModelAndSQL);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL+IQ)", linqHelper.GenerateQueryModelAndSQLAndIQuery);
            PerformanceTestHelper.TimeAndOutput(1000, message + "(QM+SQL+IQ+Execute)", linqHelper.GenerateAndExecuteQueryDBOnly);
            PerformanceTestHelper.TimeAndOutput(500, message + "(QM+SQL+IQ+Execute+re-store)", linqHelper.GenerateAndExecuteQuery);
        }
コード例 #5
0
        public void WithComplexQuery_Subqueries()
        {
            var query = (from p in QueryFactory.CreateLinqQuery <Person> ()
                         where (from c in QueryFactory.CreateLinqQuery <Client> () select c).Contains(p.Client) &&
                         p.FirstName == (from sp in QueryFactory.CreateLinqQuery <Person> () select sp.FirstName).First()
                         select p).Distinct();
            Func <IQueryable <Person> > queryGenerator = () => (query);
            var linqHelper = new LinqPerformanceTestHelper <Person> (
                queryGenerator);

            var message = "Complex query with subqueries ";

            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM)", linqHelper.GenerateQueryModel);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL)", linqHelper.GenerateQueryModelAndSQL);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL+IQ)", linqHelper.GenerateQueryModelAndSQLAndIQuery);
            PerformanceTestHelper.TimeAndOutput(1000, message + "(QM+SQL+IQ+Execute)", linqHelper.GenerateAndExecuteQueryDBOnly);
            PerformanceTestHelper.TimeAndOutput(500, message + "(QM+SQL+IQ+Execute+re-store)", linqHelper.GenerateAndExecuteQuery);
        }
コード例 #6
0
        public void WithComplexQuery_JoinsAndSubquery()
        {
            var query = (from c in QueryFactory.CreateLinqQuery <Client> ()
                         join p in QueryFactory.CreateLinqQuery <Person> () on c equals p.Client
                         join co in QueryFactory.CreateLinqQuery <Company> () on c equals co.Client
                         where p.FirstName == ((from sp in QueryFactory.CreateLinqQuery <Person> () select sp.FirstName).First())
                         select co).Distinct();
            Func <IQueryable <Company> > queryGenerator = () => (query);
            var linqHelper = new LinqPerformanceTestHelper <Company> (
                queryGenerator);

            var message = "Complex query with joins and subquery ";

            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM)", linqHelper.GenerateQueryModel);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL)", linqHelper.GenerateQueryModelAndSQL);
            PerformanceTestHelper.TimeAndOutput(10000, message + "(QM+SQL+IQ)", linqHelper.GenerateQueryModelAndSQLAndIQuery);
            PerformanceTestHelper.TimeAndOutput(1000, message + "(QM+SQL+IQ+Execute)", linqHelper.GenerateAndExecuteQueryDBOnly);
            PerformanceTestHelper.TimeAndOutput(500, message + "(QM+SQL+IQ+Execute+re-store)", linqHelper.GenerateAndExecuteQuery);
        }