Forum

    • Register
    • Login
    • Search
    • Categories

    getComponent cost

    Scripting Forum
    2
    2
    77
    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.healey
      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 Hart
        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

        17
        Online

        1.1k
        Users

        6.8k
        Topics

        62.4k
        Posts