Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

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

George_AndersonGeorge_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_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,173
    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_AndersonGeorge_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_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,173
    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
Sign In or Register to comment.