You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2023/01/10 10:38:56 UTC
[GitHub] [commons-lang] fenik17 commented on pull request #1015: Explicitly checks string for emptiness to prevent the exception logic overhead
fenik17 commented on PR #1015:
URL: https://github.com/apache/commons-lang/pull/1015#issuecomment-1377054540
@garydgregory it is minimum 1000 times difference. [Benchmark here](https://github.com/fenik17/commons-lang/blob/to_int_benchmark/src/test/java/org/apache/commons/lang3/ToIntBenchmark.java).
Results on my laptop:
```
Benchmark Mode Cnt Score Error Units
ToIntBenchmark.toIntNew_emptyString avgt 5 0,382 ± 0,016 ns/op
ToIntBenchmark.toIntNew_notNumber avgt 5 1449,161 ± 17,574 ns/op
ToIntBenchmark.toIntNew_number avgt 5 1,682 ± 0,021 ns/op
ToIntBenchmark.toIntOld_emptyString avgt 5 1456,267 ± 19,870 ns/op
ToIntBenchmark.toIntOld_notNumber avgt 5 1443,685 ± 15,124 ns/op
ToIntBenchmark.toIntOld_number avgt 5 1,683 ± 0,012 ns/op
```
Exceptions are [very expensive](https://www.baeldung.com/java-exceptions-performance).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org