It is very hard to answer this question without an MWE we can run, to see how you implemented it, what the functions look like typically, the scale of the problem, etc.
It is very hard to answer this question without an MWE we can run, to see how you implemented it, what the functions look like typically, the scale of the problem, etc.