function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Req for Feedback : Apex script performance



Just canvassing the community here for some feedback on Apex script performance.


We have been doing some pretty detailed analysis on our Apex code base to diagnose some performance issues with our application.  We were expecting to see the app getting hung up waiting for some SOQL query to execute.  Somewhat to our surprise, that turned out not to be the case; instead, we seem to be suffering from a 'death-by-a-thousand-cuts' scenario where most of the elapsed time is taken up by the execution of the Apex code itself.


Based on our debug logs, it looks like Apex script execution chugs along at a rate of roughly 10 statements per millisecond (seems to vary widely, anywhere between 5 and 15 per ms).  This is excluding all interaction with the database - strictly script execution.


Can anybody corroborate/refute this observation?  As it stands, we have web service methods in our application's back end that can execute anywhere between 10,000 and 100,000 script statements, depending on what is being asked for (and what the underlying data set size is).  Meaning, our application's FRONT end sits there for seconds on end waiting for its WS call to return.  Not a happy user experience.


Our position is, 10,000-100,000 executed statements in a method is peanuts, and 10 seconds is a long time to wait.  (Maybe this is a debatable point?) 


Any input from the community is most welcome!





Does the webservice method need to return a value that is derived by those 10,000 - 100,000 script statements?


If not, could you investigate pushign the calculation to an @future request and return from the webservice immediately?


No - it needs to return the results of that computation.  Wasn't really the question anyway.  I was more looking for other user experiences out there wrt. speed of execution of Apex code in general.