From: Jean-Philip Dumont on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i3h360$mi9$1(a)fred.mathworks.com>...
> Dear Jean-Philip,
>
> > I ran the profiler and here are the time consuming functions :
> >
> > fzero comes first with a time of 6 minutes (165 792 calls)
> > ZCC comes second with a time of 4.6 minutes (1 745 713 calls)
> > normcdf comes third with a time of 3.7 minutes (7 314 436 calls)
> > erfc comes fourth with 1.5 minutes (7 314 436 calls)
> > optimget comes fifth with 30 seconds (828 960 calls)
> > erfcore (MEX-function) comes sixth with 30 seconds (7 314 436 calls)
> >
> > After that it becomes negligeable.
> >
> > Like I said before, I have a complexe structure so it is evaluating a strategy a lot of time (because I have several scenarios).
>
> After you have used the profiler, it is worth to read the results. They tell you, that the most time is spent in FZERO, ZCC, normcdf and erfc.
> As you can see by the negligible other parts, the complicated structs are not the problem!
>
> It is a promissing strategy to accelerate the most time-consuming functions, so you should concentrate on ZCC, while FZERO and NORMCDF should not be touched, because they are built-in function. But if you call NORMCDF with a well defined set of inputs, you could try to create a local copy (with modified name) and omit the error checking parts.
>
> It is surprising that ERFC takes 1.5 min, while the actual calulations ind erfcore need 30 seconds only. The overhead of ERFC looks really small. Is it possible to call ERFCORE directly?
>
> Kind regards, Jan

Thank you for your advice!

ZCC is a simple function in which the most time consuming part of it is normcdf and in normcdf the most time consuming is erfc. Basically, there is not lots I can do. What is taking so long is that my code calls normcdf over 7 million times. The only solution I see is try to find a better starting value for fzero in order to lower the number of time I call normcdf.

I read in detail the results of the Profiler but I'm not confortable enough to start playing into this code (normcdf). I don't want it to affect my results. On top of this, the error checking part is not the time consuming part....the erfc part is.

For now, that's what i'll do. If someone have a better solution, let me know please!

Thank you again for your help! It's really appreaciated.

JP