HISE Logo Forum
    • Categories
    • Register
    • Login

    getComponent cost

    Scheduled Pinned Locked Moved Scripting
    2 Posts 2 Posters 157 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • d.healeyD
      d.healey
      last edited by

      @Christoph-Hart

      Is there an efficiency loss using getComponent throughout a script instead of using it once in on init and storing the component in a const and using the const throughout?

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        You can measure the efficiency loss with Console.start() / Console.stop(). Be aware that this operation has O(n) complexity, so it will increase for bigger projects.

        As a general rule of thumb I would suggest to keep a reference around for events that are often triggered (or if they are in the MIDI callback then it's out of the question to call the method obviously), but if it's being used just when the user presses a button, the additional 2-3 milliseconds it will take won't be noticeable.

        1 Reply Last reply Reply Quote 1
        • First post
          Last post

        56

        Online

        1.7k

        Users

        11.7k

        Topics

        102.1k

        Posts