コード例 #1
0
ファイル: RangeRepeatPerf.cs プロジェクト: wpsmith/corefx
        //[Fact]
        public void Repeat_Performance()
        {
            TimeSpan time = time = LinqPerformanceCore.Measure <int>(1, 1000, LinqPerformanceCore.WrapperType.NoWrap,
                                                                     col => Enumerable.Repeat(0, 1000000));

            LinqPerformanceCore.WriteLine("Repeat_Performance: {0}ms", time.TotalMilliseconds);
        }
コード例 #2
0
ファイル: OrderByThenByPerf.cs プロジェクト: yang73137/corefx
        private void RunTestGroup(string description, Func <IEnumerable <int>, IEnumerable <int> > linqApply)
        {
            TimeSpan time = TimeSpan.Zero;

            time = LinqPerformanceCore.Measure <int>(1000000, 100, LinqPerformanceCore.WrapperType.NoWrap, linqApply);
            LinqPerformanceCore.WriteLine(description + "_OnRawArray_Performance: {0}ms", time.TotalMilliseconds);

            time = LinqPerformanceCore.Measure <int>(1000000, 100, LinqPerformanceCore.WrapperType.IEnumerable, linqApply);
            LinqPerformanceCore.WriteLine(description + "_OnEnumerable_Performance: {0}ms", time.TotalMilliseconds);

            time = LinqPerformanceCore.Measure <int>(1000000, 100, LinqPerformanceCore.WrapperType.IReadOnlyCollection, linqApply);
            LinqPerformanceCore.WriteLine(description + "_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds);

            time = LinqPerformanceCore.Measure <int>(1000000, 100, LinqPerformanceCore.WrapperType.ICollection, linqApply);
            LinqPerformanceCore.WriteLine(description + "_OnCollection_Performance: {0}ms", time.TotalMilliseconds);
        }
コード例 #3
0
        // ============

        //[Fact]
        public void ToDictionary_Performance()
        {
            int[] array = Enumerable.Range(0, 1000000).ToArray();

            TimeSpan time = TimeSpan.Zero;

            time = LinqPerformanceCore.MeasureMaterializationToDictionary <int>(array, 100);
            LinqPerformanceCore.WriteLine("ToDictionary_OnRawArray_Performance: {0}ms", time.TotalMilliseconds);

            time = LinqPerformanceCore.MeasureMaterializationToDictionary <int>(new LinqPerformanceCore.EnumerableWrapper <int>(array), 100);
            LinqPerformanceCore.WriteLine("ToDictionary_OnEnumerable_Performance: {0}ms", time.TotalMilliseconds);

            time = LinqPerformanceCore.MeasureMaterializationToDictionary <int>(new LinqPerformanceCore.ReadOnlyCollectionWrapper <int>(array), 100);
            LinqPerformanceCore.WriteLine("ToDictionary_OnReadOnlyCollection_Performance: {0}ms", time.TotalMilliseconds);

            time = LinqPerformanceCore.MeasureMaterializationToDictionary <int>(new LinqPerformanceCore.CollectionWrapper <int>(array), 100);
            LinqPerformanceCore.WriteLine("ToDictionary_OnCollection_Performance: {0}ms", time.TotalMilliseconds);
        }