Studying an example on exception benchmark

In this final example, we will demonstrate that C++ exceptions outperform POSIX-style exceptions (a claim that is largely dependent on the hardware you're executing on, as compiler optimizations and aggressive branch prediction can improve the performance of POSIX-style error handling).

POSIX-style error handling requires the user to check the result of a function each time it is executed. When function nesting occurs (which will almost certainly happen), this issue is exacerbated even further. In this example, we will take this case to the extreme, creating a recursive function that checks the results of itself thousands of times, while executing the test hundreds of thousands of times. Each test ...

Get Hands-On System Programming with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.