Closed tdltdl closed 9 years ago
Hi @tdeleeuw I see your point of not validating check digit as it get's calculated anyway. Are you dealing with huge numbers ? and is it going to ease you apps SLAs if we optimize 14% cpu time per iban you mentioned ?
Hi @arturmkrtchyan,
The application I am working on has of generate a lot of data. Most of it is IBAN related, hence any gain I can have will help me to speed up the processing drastically. In my case, disabling the validation fully allows me to generate the data about 20~25% faster (as I get rid of 33% of time in IBAN).
I understand that the prime focus of the library is not to be as fast as possible, but as the patch is available, it should not be an issue to merge it with the code (as you see, the patch is very minimal and the one that disables the computation of the check digit when build is invoked is also very straight forward)
I have other local changes that speed it up even further and reduce the gc footprint. For this I needed to change some private method signatures to get a char array instead of a String.
The Benchmark test (just changed from 1 000 000 to 10 000 000 loops) Original code: IbanBenchmark.ibanConstruction: [measured 3 out of 4 rounds, threads: 1 (sequential)] round: 8.09 [+- 0.03], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 210, GC.time: 0.18, time.total: 32.63, time.warmup: 8.35, time.bench: 24.28 IbanBenchmark.ibanValidation: [measured 3 out of 4 rounds, threads: 1 (sequential)] round: 3.42 [+- 0.01], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 32, GC.time: 0.06, time.total: 13.64, time.warmup: 3.39, time.bench: 10.25
After patch:
IbanBenchmark.ibanConstruction: [measured 3 out of 4 rounds, threads: 1 (sequential)] round: 4.79 [+- 0.01], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 108, GC.time: 0.11, time.total: 19.45, time.warmup: 5.10, time.bench: 14.36 IbanBenchmark.ibanValidation: [measured 3 out of 4 rounds, threads: 1 (sequential)] round: 1.59 [+- 0.02], round.block: 0.00 [+- 0.00], round.gc: 0.00 [+- 0.00], GC.calls: 11, GC.time: 0.02, time.total: 6.35, time.warmup: 1.57, time.bench: 4.78
Let me know if you are interested in this patch.
Best regards
Thierry
Hi @tdeleeuw I'm going to merge this one so you can skip the whole validation if want. Thanks for the PR. Regarding GC optimization string to chars etc... Believe me I'm a big fun of performance optimization but I don't think I should be doing this here.
Hi,
I have a use case where I generate random IBANs for test purpose. As I am using the BBAN structure to generate the data, I am sure that the data loaded is valid.
About 33% of the time of the build method is spent in validation (and 14.4% is spent in check digit validation - which is useless as the build computes it).
This patch allows to simply prevent validation to be executed globally.
I can push another patch to have a validation without computing the check digit for the particular case of the build methods if you like. Let me know.
Thanks!
Thierry