private static void SimpleComparisonLoop <T>(AdvancedComparerStruct <T> c, T o1, T o2, int count)
 {
     for (int i = 0; i < count; i++)
     {
         c.Equals(o1, o2);
     }
 }
        private static void ArrayComparisonLoop <T>(AdvancedComparerStruct <T> c, T[] array, int count)
        {
            int length = array.Length;

            for (int j = 0; j < count; j++)
            {
                for (int i = 0; i < length - 1;)
                {
                    c.Equals(array[i], array[++i]);
                }
            }
        }
        public void PerformanceTest()
        {
            AdvancedComparerStruct <Xtensive.Tuples.Tuple> comparer = AdvancedComparerStruct <Xtensive.Tuples.Tuple> .Default;

            Xtensive.Tuples.Tuple t   = Xtensive.Tuples.Tuple.Create(1, 2);
            Xtensive.Tuples.Tuple ct  = t.ToRegular();
            Xtensive.Tuples.Tuple wt  = t.ToReadOnly(TupleTransformType.TransformedTuple);
            Xtensive.Tuples.Tuple wtc = t.ToReadOnly(TupleTransformType.TransformedTuple);
            int count = IterationCount;

            comparer.Equals(t, ct);
            comparer.Equals(t, wt);
            comparer.Equals(wt, wtc);

            TestHelper.CollectGarbage();
            using (new Measurement("O&O", MeasurementOptions.Log, count))
                for (int i = 0; i < count; i++)
                {
                    comparer.Equals(t, ct);
                }

            TestHelper.CollectGarbage();
            using (new Measurement("O&W", MeasurementOptions.Log, count))
                for (int i = 0; i < count; i++)
                {
                    comparer.Equals(t, wt);
                }

            TestHelper.CollectGarbage();
            using (new Measurement("W&W", MeasurementOptions.Log, count))
                for (int i = 0; i < count; i++)
                {
                    comparer.Equals(wt, wtc);
                }
        }
        public void PerformanceTransformTesting(Xtensive.Tuples.Tuple tuple1, Xtensive.Tuples.Tuple tuple2, Xtensive.Tuples.Tuple tuple3, Xtensive.Tuples.Tuple tuple4)
        {
            int count = IterationCount;

            AdvancedComparerStruct <Xtensive.Tuples.Tuple> comparer = AdvancedComparerStruct <Xtensive.Tuples.Tuple> .Default;

            comparer.Equals(tuple1, tuple2);
            comparer.Equals(tuple1, tuple3);
            comparer.Equals(tuple3, tuple4);

            TestHelper.CollectGarbage();
            using (new Measurement("O&O", MeasurementOptions.Log, count))
                for (int i = 0; i < count; i++)
                {
                    comparer.Equals(tuple1, tuple2);
                }

            TestHelper.CollectGarbage();
            using (new Measurement("O&W", MeasurementOptions.Log, count))
                for (int i = 0; i < count; i++)
                {
                    comparer.Equals(tuple1, tuple3);
                }

            TestHelper.CollectGarbage();
            using (new Measurement("W&W", MeasurementOptions.Log, count))
                for (int i = 0; i < count; i++)
                {
                    comparer.Equals(tuple3, tuple4);
                }
        }
        public void PerformanceTest2()
        {
            AdvancedComparerStruct <Xtensive.Tuples.Tuple> comparer = AdvancedComparerStruct <Xtensive.Tuples.Tuple> .Default;

            Xtensive.Tuples.Tuple t  = Xtensive.Tuples.Tuple.Create(1);
            CombineTransform      mt = new CombineTransform(false, t.Descriptor, t.Descriptor, t.Descriptor, t.Descriptor);
            SegmentTransform      st = new SegmentTransform(false, mt.Descriptor, new Segment <int>(1, 2));

            Xtensive.Tuples.Tuple wt1 = st.Apply(TupleTransformType.TransformedTuple, mt.Apply(TupleTransformType.TransformedTuple, t, t, t, t));
            Xtensive.Tuples.Tuple wt2 = st.Apply(TupleTransformType.TransformedTuple, mt.Apply(TupleTransformType.TransformedTuple, t, t, t, t));
            Xtensive.Tuples.Tuple ct1 = st.Apply(TupleTransformType.Tuple, mt.Apply(TupleTransformType.Tuple, t, t, t, t));
            Xtensive.Tuples.Tuple ct2 = st.Apply(TupleTransformType.Tuple, mt.Apply(TupleTransformType.Tuple, t, t, t, t));
            int count = IterationCount;

            comparer.Equals(ct1, ct2);
            comparer.Equals(ct1, wt1);
            comparer.Equals(wt1, wt2);

            TestHelper.CollectGarbage();
            using (new Measurement("O&O", MeasurementOptions.Log, count))
                for (int i = 0; i < count; i++)
                {
                    comparer.Equals(ct1, ct2);
                }

            TestHelper.CollectGarbage();
            using (new Measurement("O&W", MeasurementOptions.Log, count))
                for (int i = 0; i < count; i++)
                {
                    comparer.Equals(ct1, wt1);
                }

            TestHelper.CollectGarbage();
            using (new Measurement("W&W", MeasurementOptions.Log, count))
                for (int i = 0; i < count; i++)
                {
                    comparer.Equals(wt1, wt2);
                }
        }