3 ms·
Throw in Java is very inexpensive. Expensive part is creating new instance of exception, which figures out stack trace and creates bunch of immutable strings.
by bluestreak 7y ago
Throw in Java is very inexpensive. Expensive part is creating new instance of exception, which figures out stack trace and creates bunch of immutable strings.
There is a technique of throwing existing static instance of exception, which generates no garbage and two orders of magnitude faster than traditional java approach:
https://github.com/questdb/questdb/blob/7560895ee400c82b0e5e39440eaf6c55bbbb7d7d/core/src/main/java/io/questdb/cutlass/text/types/InputFormatConfiguration.java#L207 https://github.com/questdb/questdb/blob/7560895ee400c82b0e5e...
The only downside is that stack trace is effectively defunct.