Showing results 1 to 2 of 2

Thread: IVariableCollection and LINQ/object access performance

  1. #1
    Join Date
    31.05.2018
    Posts
    5

    Default IVariableCollection and LINQ/object access performance

    Hello All, 

    I am facing an interesting issue with the AddIn framework which I am struggling with for a while now.

    Suppose I am developing a Project Service Extension AddIn which does some background work (using TPL) on selected zenon variables. The service searches for a matching variable (or variables) in the IVariableCollection and does some processing. 

    context.VariableCollection.Where(x => x.Name.Contains("Variable_Temp"));

    Now, obviously, this works as intended and I get an IEnumerable containing matching objects - and it's fast enough (as expected - usually takes less than 5 ms for a rather complex project) but then I want to access an IVariable object inside my IEnumerable - and let's say I want to access any object inside it by using FirstOrDefault()

    context.VariableCollection.Where(x => x.Name.Contains("Variable_Temp")).FirstOrDefault();

    or by simply calling

    context.VariableCollection.FirstOrDefault(x => x.Name.Contains("Variable_Temp"));

    and this simple operation takes anywhere between ~3000-6000ms on my development node which is absolutely unacceptable - maybe I am missing something important, but I honestly have no idea what.

    Obviously, if I refer to the variable inside the collection by its exact name (i.e. like below) it takes less than 5 ms each time.

    context.VariableCollection["Variable_Temp"];

    So - the question is - how can I quickly search for and access IVariable objects inside IVariableCollection not knowing their exact name or the value of any other property? Thanks for any tips.

    Best regards, 
    Mikolaj

  2. #2
    Join Date
    31.05.2018
    Posts
    5

    Default Re: IVariableCollection and LINQ/object access performance

    Found a satisfactory workaround. Seems to me that AddIn collections simply don't like Where clauses 

Similar Threads

  1. Performance des 3S ARTI NG Treibers
    By elso in forum Drivers
    Replies: 3
    Last Post: 11th June 2014, 10:23
  2. zenOn performance metrics
    By stolyarov_as in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 7
    Last Post: 18th September 2013, 00:45
  3. Replies: 7
    Last Post: 16th October 2012, 14:55
  4. IPA - Industrial Performance Analyser
    By judo20 in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 2
    Last Post: 6th June 2011, 13:02
  5. Performance?
    By dak2483 in forum Engineering Studio & Service Engine (former zenon Editor & Runtime)
    Replies: 3
    Last Post: 19th August 2008, 13:55

Tags for this Thread

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •