Announcement

Collapse
No announcement yet.

Perfomance efsExternal vs efsInternal

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Perfomance efsExternal vs efsInternal

    I am calling a short efsExternal script from my main script and wondered if my main script would run substantially faster if I convert the external script to efsInternal.

    Both scripts are encrypted and license protected, so I assume by being external the one script is decrypted and license checked every time it is called, meaning on every tick?

    The external file is less than a third the size of the main efs and runs on a different interval. How would I convert it to internal?...perhaps create as a function and use a flag to avoid the main text? Will this substantially increase performance?

    Is there a source of information that specifically addresses increasing efs performance? Do's and dont's?

    Thanks in advance.

  • #2
    Re: Perfomance efsExternal vs efsInternal

    Hello ratherBgolfing,

    Originally posted by ratherBgolfing
    I am calling a short efsExternal script from my main script and wondered if my main script would run substantially faster if I convert the external script to efsInternal.
    In general, yes, it would be more efficient.

    Both scripts are encrypted and license protected, so I assume by being external the one script is decrypted and license checked every time it is called, meaning on every tick?
    It depends on how you are making your efsExternal call. If you assign a global variable to the call only once, then you will not be making the call on every tick.

    if (myGlobal == null) myGlobal = efsExternal("filename.efs");

    This creates the initial series object. On every subsequent tick, your study only references the existing series.

    If you make the efsExternal() call every tick like below.

    myGlobal = efsExternal("filename.efs");

    The EFS2 engine is smart enough to check to see if this series already has been created and if it has it will just reference the existing series. This method will work fine, but is less efficient because you are making the EFS2 engine check to see if that series already exists on every tick.

    The external file is less than a third the size of the main efs and runs on a different interval. How would I convert it to internal?...perhaps create as a function and use a flag to avoid the main text? Will this substantially increase performance?
    You should be able to just copy main() from the external formula into your other formula and rename the function. If the main() function in the external formula is also using some other user-defined functions, then they also must be brought over to your study. Those would most likely not have to be renamed since they would be unique function names already. Then change your calls from efsExternal() to efsInternal() where you call the internal function name rather than the exteranal file name.

    Is there a source of information that specifically addresses increasing efs performance? Do's and dont's?

    Thanks in advance.
    There is not one specific resource but you can find lots of tips and tricks throughout the documentation in the EFS KnowledgeBase as well as here in the forums.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Thanks Jason. Great detailed answer.

      I should mention that I really like the Undo button in Editor. My efs was working great using efsExternal until I started playing around with it to make it faster. Obviously I botched up the conversion to internal. Will try that again later.

      In the meantime I backed out of my mess and tried the global variable solution you suggested. I had been using, in my main():

      var vTrend = efsExternal(.......);

      So I was calling it on every tick like you said. Not efficient.

      So I declared the variable before the preMain() as:
      var vTrend = 0; // set to zero since I learned using "null" that efsExternal does not pass strings

      And then I used, in the main():

      if (vTrend == 0) vTrend = efsExternal(......);

      This works as far as results are concerned, with one strange addition. I printed vTrend below each bar to debug/test and found it prints as [object series] instead of as -1 or 1. The efsExternal must be returning -1 or 1 for me to get my correct results....or is it?

      So I loaded the external efs directly into a chart and it is running fine ....it prints -1 or 1 below each bar.

      So why is my main efs printing [object series] ?

      Thanks again.

      Comment


      • #4
        Hello ratherBgolfing,

        When you use efsExternal() or efsInternal() the result is a Series Object. A Series Object is an enhanced array that contains a value for each bar in the chart that has a valid calculation. If you try to send the Series Object to the debugPrintln(vTrend) function the EFS engine would normally try print all the values in the array to the output window. This behavior is being prevented by the EFS2 engine because it could be a potentially large amount of data to print. If you just want to look at a specific value of the series use the .getValue(0) method. Try the following.

        debugPrintln(getCurrentBarIndex() + " vTrend = " + vTrend.getValue(0));
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Right. Thanks. I had forgotten that.

          I am now using :

          drawText(vTrend.getValue(0), BelowBar4);

          which works fine.

          Thanks again.

          Will try the efsInternal now.....keep an eye open....lol

          Comment


          • #6
            Jason

            Internal running fine now....we will see if it is faster....one less file to manage anyway.

            Thanks

            Comment

            Working...
            X