Pre loader

Insert performance

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1
0

I’m trying to merge xvalues of two data series (both must have equals xvalues).
First, i get a keys – collection of different keys, and want to insert this keys into second data series.

        using (ds.SuspendUpdates())
        {
                int keyIndex = 0;
                int dsIndex = ds.FindIndex(keys[0], SearchMode.RoundUp);

                while (dsIndex < ds.XValues.Count)
                {
                    if (keyIndex >= keys.Count) break;

                    if (ds.XValues[dsIndex] > keys[keyIndex])
                    {
                        ds.Insert(dsIndex, keys[keyIndex], Double.NaN);
                        keyIndex++;
                    }

                    dsIndex++;
                }
       }

But if ds.XValues.Count = 1200000 and keys’s count = 200000, that this method work to much time.
Complexity of this method is O(n), so i want to know what is performance (complexity) of data series insert method?

  • You must to post comments
1
0

Hi Arthur,

Insert performance will be roughly the same as List.Insert, where we have one list for each column. E.g. Date, Open, High, Low, Close are 5 lists.

Insert requires that the underlying list is resized, all elements after the Insert are copied (moved) and the new elements copied (inserted).

DataSeries.InsertRange is a faster and better way to insert than point-by-point insert.

Hope this helps,
Andrew

  • Ivan Zakharov
    Data to insert often don't point-by-point. Is there any way to create a data series with a parameter capacity (like new List(capacity))?
  • Andrew Burnett-Thompson
    Not at this time, no. The append performance is very fast. Inserts require a resize, copy and move operation so are slower than appends. If you can, try to re-write your code to iterate over two series and only use Append in order.
  • Andrew Burnett-Thompson
    Something else you can try is merging to a List List with pre-defined capacity then appending one block using DataSeries.Append(xVaues, yValues). It will use more memory but should be quicker!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies