3 ms·
> In .NET and Java it costs at least 100x as much time to throw an exceptions as to return an error code. The conjecture is that if checks are always executed
by jayd16 2y ago
> In .NET and Java it costs at least 100x as much time to throw an exceptions as to return an error code.
The conjecture is that if checks are always executed while exceptions are free when not thrown.
That said, predicted branches are also fairly free so arguing about this in the abstract is pointless.
- rocqua 2y agoIn the margin, branches are more likely close to the hot path, so they are more likely to 'pollute' the instruction cache. Whilst exceptions have less of this. Though profile guided optimization will probably catch this. And it might be that even without, compilers still optimize around this.