public IEnumerable <TestConfigurationWithQueryRange> TestCasesWithQueryRange()
        {
            var sizes    = TestFactoryHelper.Sizes;
            var dataSets = TestFactoryHelper.DataSets;

            foreach (var implementationType in ImplementationTypes)
            {
                foreach (var dataset in dataSets)
                {
                    if (TestFactoryHelper.IsFinite(implementationType.Name) && dataset.HasOverlaps)
                    {
                        continue;
                    }

                    // Get an instance with minimal overload impact to get identifier:
                    var minimalImpact = CreateIntervalCollection(implementationType, dataset, 1);

                    foreach (var size in sizes)
                    {
                        foreach (var queryRangeName in CreateQueryRangesNames())
                        {
                            var identifier = string.Format("{0}_{1}", GetIdentifier(minimalImpact, implementationType), queryRangeName);
                            var prepare    = new Action <IPerformanceTestCaseConfiguration>(i =>
                            {
                                var config = (TestConfigurationWithQueryRange)i;
                                var data   = CreateIntervalCollection(implementationType, dataset, size);
                                config.IntervalCollection = CreateIntervalCollection(implementationType, dataset, size);
                                config.QueryRange         = CreateQueryRange(queryRangeName, data);
                                config.Median             = config.IntervalCollection.Span.Middle();
                            });


                            yield return
                                (new TestConfigurationWithQueryRange
                            {
                                TargetImplementationType = implementationType,
                                Identifier = identifier,
                                NumberOfIntervals = size,
                                DataSetName = dataset.Name,
                                QueryRangeName = queryRangeName,
                                Prepare = prepare,
                            });
                        }
                    }
                }
            }
        }
        public IEnumerable <TestConfiguration> TestCases()
        {
            var sizes    = TestFactoryHelper.Sizes;
            var dataSets = TestFactoryHelper.DataSets;

            foreach (var implementationType in ImplementationTypes)
            {
                foreach (var dataset in dataSets)
                {
                    if (TestFactoryHelper.IsFinite(implementationType.Name) && dataset.HasOverlaps)
                    {
                        continue;
                    }

                    // Get an instance with minimal overload impact to get identifier:
                    var minimalImpact = CreateIntervalCollection(implementationType, dataset, 1);
                    var identifier    = GetIdentifier(minimalImpact, implementationType);

                    foreach (var size in sizes)
                    {
                        var prepare = new Action <IPerformanceTestCaseConfiguration>(i =>
                        {
                            var config = (TestConfiguration)i;
                            config.IntervalCollection = CreateIntervalCollection(implementationType, dataset, size);
                        });

                        yield return
                            (new TestConfiguration
                        {
                            TargetImplementationType = implementationType,
                            Identifier = identifier,
                            NumberOfIntervals = size,
                            DataSetName = dataset.Name,
                            Prepare = prepare,
                        });
                    }
                }
            }
        }
Example #3
0
        public IEnumerable <CreateIntervalCollectionTestConfiguration> TestCases()
        {
            var dataSets = TestFactoryHelper.DataSets;
            var sizes    = TestFactoryHelper.Sizes;

            foreach (var implementation in ImplementationTypes)
            {
                foreach (var dataset in dataSets)
                {
                    foreach (var size in sizes)
                    {
                        if (TestFactoryHelper.IsFinite(implementation.Name) && dataset.HasOverlaps)
                        {
                            continue;
                        }

                        Action <IPerformanceTestCaseConfiguration> prepare;
                        Action <IPerformanceTestCaseConfiguration> run;
                        // Get an instance with minimal overload impact to get identifier:
                        var minimalImpact = CreateIntervalCollection(implementation, dataset, 1);
                        var identifier    = GetIdentifier(minimalImpact, implementation);

                        if (HasParameterlessConstructor(implementation))
                        {
                            prepare = i =>
                            {
                                var config = (CreateIntervalCollectionTestConfiguration)i;
                                config.Data = dataset.IntervalsFactory(size);
                                config.GenericCreatableType = GetGenericCreatableType(implementation);
                            };

                            run = i =>
                            {
                                var config = (CreateIntervalCollectionTestConfiguration)i;
                                config.IntervalCollection = config.GenericCreatableType
                                                            .TryCreateInstanceWithValues() as IIntervalCollection <IInterval <int>, int>;
                                config.IntervalCollection.AddAll(config.Data);
                            };
                        }
                        else
                        {
                            prepare = i =>
                            {
                                var config = (CreateIntervalCollectionTestConfiguration)i;
                                config.Data = dataset.IntervalsFactory(size);
                                config.GenericCreatableType = GetGenericCreatableType(implementation);
                                config.Parameters           = new Dictionary <string, object> {
                                    { "intervals", config.Data }
                                };
                            };

                            run = i =>
                            {
                                var config = (CreateIntervalCollectionTestConfiguration)i;
                                config.GenericCreatableType.TryCreateInstance(config.Parameters);
                            };
                        }

                        yield return(new CreateIntervalCollectionTestConfiguration
                        {
                            TargetImplementationType = implementation,
                            Identifier = identifier,
                            NumberOfIntervals = size,
                            DataSetName = dataset.Name,
                            Prepare = prepare,
                            Run = run
                        });
                    }
                }
            }
        }