Ejemplo n.º 1
0
        public bool ComplicatedLinqFast(Stopwatch watch, int repeatCount, int takeCount)
        {
            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                {
                    var q =
                        (
                            from n1 in db.Narrows
                            join n2 in db.Narrows on new { n1.ID, n1.Field1 } equals new { n2.ID, n2.Field1 }
                            where n1.ID < 100 && n2.Field1 <= 50
                            group n1 by n1.ID into gr
                            select new
                    {
                        gr.Key,
                        Count = gr.Count()
                    }
                        )
                        .OrderBy(n1 => n1.Key)
                        .Skip(1)
                        .Take(takeCount);

                    foreach (var item in q)
                    {
                    }
                }
            }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 2
0
        public bool SimpleLinqQuery(Stopwatch watch, int repeatCount, int takeCount)
        {
            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                {
                    var q =
                        (
                            from n1 in db.Narrows
                            where n1.ID < 100
                            select n1.ID
                        )
                        .Take(takeCount);

                    foreach (var item in q)
                    {
                    }
                }
            }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 3
0
        public bool GetSingleColumnSlow(Stopwatch watch, int repeatCount, int takeCount)
        {
            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                    db.Narrows.Where(t => t.ID == 1).Select(t => t.ID).AsEnumerable().First();
            }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 4
0
        public bool GetSingleColumnParam(Stopwatch watch, int repeatCount, int takeCount)
        {
            watch.Start();

            using (var db = new L2SContext(TrackChanges))
                for (var i = 0; i < repeatCount; i++)
                {
                    db.ExecuteQuery <int>("SELECT ID FROM Narrow WHERE ID = {0} AND Field1 = {1}", 1, 2);
                }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 5
0
        public bool GetSingleColumnSlow(Stopwatch watch, int repeatCount, int takeCount)
        {
            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                    db.ExecuteQuery <int>(GetSingleColumnSql);
            }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 6
0
        public bool ComplicatedLinqSlow(Stopwatch watch, int repeatCount, int takeCount, int nRows)
        {
            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                {
                    var q =
                        (
                            from n in db.NarrowLongs
                            join w in db.WideLongs on n.Field1 equals w.Field1
                            where
                            n.ID >= 0 && n.ID <= nRows &&
                            !new[] { 0, 20, 50, 187635 }.Contains(w.Field1)
                            select new
                    {
                        n.ID,
                        w.Field1
                    }
                        )
                        .Union
                        (
                            from n in db.NarrowLongs
                            join w in db.WideLongs on n.Field1 equals w.Field1
                            where
                            n.ID >= 0 && n.ID <= nRows &&
                            !new[] { 0, 240, 500, 18635 }.Contains(w.Field1)
                            select new
                    {
                        n.ID,
                        w.Field1
                    }
                        )
                        .OrderByDescending(n1 => n1.Field1)
                        .Skip(1000)
                        .Take(takeCount);

                    foreach (var item in q)
                    {
                    }
                }
            }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 7
0
        public bool GetWideList(Stopwatch watch, int repeatCount, int takeCount)
        {
            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                    foreach (var item in db.WideLongs.Take(takeCount))
                    {
                    }
            }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 8
0
        public bool GetSingleColumnParam(Stopwatch watch, int repeatCount, int takeCount)
        {
            watch.Start();

            using (var db = new L2SContext(TrackChanges))
                for (var i = 0; i < repeatCount; i++)
                {
                    var id = 1;
                    var p  = 2;
                    db.Narrows.Where(t => t.ID == id && t.Field1 == p).Select(t => t.ID).AsEnumerable().First();
                }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 9
0
        public bool GetSingleColumnParam(Stopwatch watch, int repeatCount, int takeCount)
        {
            var query = CompiledQuery.Compile((L2SContext db, int id, int p) =>
                                              db.Narrows.Where(t => t.ID == id && t.Field1 == p).Select(t => t.ID).First());

            watch.Start();

            using (var db = new L2SContext(TrackChanges))
                for (var i = 0; i < repeatCount; i++)
                {
                    query(db, 1, 2);
                }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 10
0
        public bool GetSingleColumnSlow(Stopwatch watch, int repeatCount, int takeCount)
        {
            var query = CompiledQuery.Compile((L2SContext db) =>
                                              db.Narrows.Where(t => t.ID == 1).Select(t => t.ID).First());

            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                    query(db);
            }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 11
0
        public bool GetWideList(Stopwatch watch, int repeatCount, int takeCount)
        {
            var sql = GetWideListSql(takeCount);

            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                    foreach (var item in db.ExecuteQuery <WideLong>(sql))
                    {
                    }
            }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 12
0
        public bool GetWideList(Stopwatch watch, int repeatCount, int takeCount)
        {
            var query = CompiledQuery.Compile((L2SContext db, int top) =>
                                              db.WideLongs.Take(top));

            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                    foreach (var item in query(db, takeCount))
                    {
                    }
            }

            watch.Stop();

            return(true);
        }
Ejemplo n.º 13
0
        public bool SimpleLinqQuery(Stopwatch watch, int repeatCount, int takeCount)
        {
            var query = CompiledQuery.Compile((L2SContext db, int top) =>
                                              (
                                                  from n1 in db.Narrows
                                                  where n1.ID < 100
                                                  select n1.ID
                                              )
                                              .Take(top));

            watch.Start();

            for (var i = 0; i < repeatCount; i++)
            {
                using (var db = new L2SContext(TrackChanges))
                    foreach (var item in query(db, takeCount))
                    {
                    }
            }

            watch.Stop();

            return(true);
        }