Speed of exception throwing and catching

7 views (last 30 days)
Matthew
Matthew on 12 Jul 2012
Hi,
I'm trying to analyse the exact time involved in throwing and catching an exception (I've used the profiler practically to get time in ms, but am interested in how and why this corresponds to clock cyles, I'm just trying to get a more theoretical understanding). I'm looking for an exact number of clock cycles.
How many clock cycles are used to throw an exception and how many clock cycles are used to catch that exception and what does on during the throwing/catching process to cause those clock cycles to be used?
With many thanks,
Froskoy.

Answers (1)

Jan
Jan on 12 Jul 2012
I'm convinced, that PROFILE does not allow to measure processor cycles for specific commands. On one hand PROFILE disables the JIT acceleration, on the other hand the clock used by PROFILE has a course precision only (0.01 or 0.001 sec, as far as I remember).
The FEX: High-Accuracy-Timer offers a higher precision under Windows. But this program has a distinct overhead itself, such that you have to be very careful.
I'm using TRY/CATCH to save hours (days!) of debugging, therefore I do not care much about processor cycles as long as my 200'000 lines of code program runs in less than 5 seconds.
  2 Comments
Matthew
Matthew on 12 Jul 2012
Thanks. I've edited for clarity RE the profiler. I'm more interested in details of how exceptions are implemented in the MATLAB language and how this corresponds to number of clock cycles taken to execute the code.
Do you also know of a good memory analyser (external to MATLAB) that I can use to see where MATLAB is allocating memory?
Jan
Jan on 12 Jul 2012
I assume that all tools I know violate the license conditions, which forbid a reverse engineering.
On the other hand (at least) in earlier Matlab versions (2009a as far as I remember) you can enable different memory managers at startup. But adjusting a Matlab program to a specific memory manager is not a good idea, because the next Matlab release could use a different approach already.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!