[FS} Speed of functions defined in versioned document versus same document

George_Anderson
George_Anderson Member Posts: 71 ✭✭
Is there a reason to expect a performance boost when calling a function from an imported versioned document as opposed to importing from another file in the same document?

As an example, I copied a low-level function (`project`) from the FS stdlib into my document and renamed it 'local_project'. The profiler shows that calling 'local_project' is nearly twice as slow as calling the one in stdlib, despite no modifications. Is there a reason to expect this, and does it imply that I could get better performance by refactoring code into separate documents?
Tagged:

Comments

  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,278 image
    There should be no difference (at least in functions like this).  I expect what you're seeing is due to variance in the profiling, especially for small time intervals -- you have to run 'project' a lot of times before you get a reliable performance estimate. 
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • George_Anderson
    George_Anderson Member Posts: 71 ✭✭
    @ilya_baran Here's a document demonstrating the problem (speed difference solidly verified by 1000 calls, or you can increase it).


    It turns out it has something to do with imported stdlib versions. I have two featurescript tabs -- if the stdlib version I import is different in the two tabs (e.g. I used 1549 and 1540, but any two different versions in either tab seems to demonstrate the problem), then the version "locally imported" from the library tab is about 40% slower, while the direct import from the library and a locally defined copy in the same tab don't change speed.

  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,278 image
    Interesting -- there is clearly an effect from mixing different std versions.  Without profiling the internals, I can't immediately explain it, though I have some guesses.  Regardless, not mixing stds has performance benefits outside what is measured during execution, so that remains the recommendation.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc