예제 #1
0
        private void CachedRseQueryTest(int count)
        {
            var d = Domain;

            using (var ss = d.OpenSession()) {
                var s = ss.Session;
                using (var ts = s.OpenTransaction()) {
                    TestHelper.CollectGarbage();
                    var pKey = new Parameter <Tuple>();
                    var rs   = d.Model.Types[typeof(Simplest)].Indexes.PrimaryIndex.ToRecordSet();
                    rs = rs.Seek(() => pKey.Value);
                    using (new ParameterScope()) {
                        using (warmup ? null : new Measurement("Cached RSE Query", count)) {
                            for (int i = 0; i < count; i++)
                            {
                                pKey.Value = Tuple.Create(i % instanceCount);
                                var es = rs.ToEntities <Simplest>();
                                foreach (var o in es)
                                {
                                    // Doing nothing, just enumerate
                                }
                            }
                        }
                        ts.Complete();
                    }
                }
            }
        }
예제 #2
0
        private void FetchTest(int count)
        {
            var d = Domain;

            using (var ss = d.OpenSession()) {
                var  s   = ss.Session;
                long sum = (long)count * (count - 1) / 2;
                using (var ts = s.OpenTransaction()) {
                    TestHelper.CollectGarbage();
                    using (warmup ? null : new Measurement("Fetch & GetField", count)) {
                        for (int i = 0; i < count; i++)
                        {
                            var key = Key.Create <Simplest>(Tuple.Create((long)i % instanceCount));
                            var o   = key.Resolve <Simplest>();
                            sum -= o.Id;
                        }
                        ts.Complete();
                    }
                }
                if (count <= instanceCount)
                {
                    Assert.AreEqual(0, sum);
                }
            }
        }