I have a method CalculateLinearRegression()
that calls the LinEst
function of an Excel.Application.WorksheetFunction
class. LinEst
is called roughly 3,500 times each time CalculateLinearRegression()
is called. I inject the WorksheetFunction class into my method so I know that only one instance of the class gets created.
Each call of CalculateLinearRegression()
takes around 10 minutes and I am certain it is the LinEst
function that is slowing everthing down (removing the call to LinEst
and hard coding the results means the method to run in a couple of seconds).
I appreciate that LinEst
is doing a fair bit of computation, but I doubt it's doing so much as to cause this delay, therefore I think it is probably the call to the Excel function that is adding on the lag. Does anyone know of either a way of speeding this up, or a C# direct replacement for the LinEst
function?