public static IFunction CreateSimpleFunction(IFunctionStore store) { var function = new Function("test"); store.Functions.Add(function); // initialize schema IVariable x = new Variable <double>("x", 3); IVariable y = new Variable <double>("y", 2); IVariable f1 = new Variable <double>("f1"); function.Arguments.Add(x); function.Arguments.Add(y); function.Components.Add(f1); // write some data var xValues = new double[] { 0, 1, 2 }; var yValues = new double[] { 0, 1 }; var fValues = new double[] { 100, 101, 102, 103, 104, 105 }; function.SetValues(fValues, new VariableValueFilter <double>(x, xValues), new VariableValueFilter <double>(y, yValues), new ComponentFilter(f1)); return(function); }
public void RefreshShouldBeFastWhenFunctionDataSourceHasManyChanges() { var random = new Random(); IFunction function = new Function { Arguments = { new Variable <int>("x") }, Components = { new Variable <int>("f") } }; int count = 1000; var componentvalues = Enumerable.Range(1, count).Select(i => random.Next(100)).ToArray(); var argumentvalues = Enumerable.Range(1, count).ToArray(); var chartView = new ChartView(); var lineSeries = ChartSeriesFactory.CreateLineSeries(); var functionBindingList = new FunctionBindingList(function) { SynchronizeInvoke = chartView }; lineSeries.DataSource = functionBindingList; //don't update on every change... lineSeries.UpdateASynchronously = true; lineSeries.XValuesDataMember = function.Arguments[0].DisplayName; lineSeries.YValuesDataMember = function.Components[0].DisplayName; chartView.Chart.Series.Add(lineSeries); lineSeries.PointerVisible = false; // call one time to make sure that internal HACK TypeUtils.CallGeneric is done, otherwise timing varies a lot function.SetValues(componentvalues, new VariableValueFilter <int>(function.Arguments[0], argumentvalues)); function.Arguments[0].Clear(); // now do the same when table view is shown Action <Form> onShown = delegate { //the slowdown of chart is absolute minimal TestHelper.AssertIsFasterThan(50, () => function.SetValues(componentvalues, new VariableValueFilter <int>(function.Arguments[0], argumentvalues))); }; WindowsFormsTestHelper.ShowModal(chartView, onShown); }