[bisq-network/bisq] Cache results of isFiatCurrency and isCryptoCurrency (#4955)

chimp1984 notifications at github.com
Tue Dec 15 14:59:52 CET 2020


Thanks @stejbac for the review and comments!

I just did some measurments:
CurrencyUtil2 is the version from that PR, CurrencyUtil the master version.

With wrong Fiat, wrong crypto
Dec-15 08:47:47.029 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil2.isCryptoCurrency for 100000000 iterations took 1937 ms 
Dec-15 08:47:48.910 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil2.isFiatCurrency for 100000000 iterations took 1881 ms 
Dec-15 08:47:51.882 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil.isCryptoCurrency for 100000000 iterations took 2972 ms 
Dec-15 08:47:54.016 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil.isFiatCurrency for 100000000 iterations took 2134 ms 

With correct Fiat and crypto
Dec-15 08:48:48.699 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil2.isCryptoCurrency for 100000000 iterations took 1791 ms 
Dec-15 08:48:50.596 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil2.isFiatCurrency for 100000000 iterations took 1897 ms 
Dec-15 08:48:52.714 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil.isCryptoCurrency for 100000000 iterations took 2117 ms 
Dec-15 08:48:56.286 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil.isFiatCurrency for 100000000 iterations took 3572 ms 

With correct Fiat and crypto using concurrentHashMap in CurrencyUtil2
Dec-15 08:49:37.739 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil2.isCryptoCurrency for 100000000 iterations took 1752 ms 
Dec-15 08:49:39.516 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil2.isFiatCurrency for 100000000 iterations took 1777 ms 
Dec-15 08:49:41.637 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil.isCryptoCurrency for 100000000 iterations took 2121 ms 
Dec-15 08:49:45.104 [SeedNodeMain] ERROR b.s.SeedNode: CurrencyUtil.isFiatCurrency for 100000000 iterations took 3467 ms 

It seems the Currency.getInstance(currencyCode) is the "expensive" one. 
The difference is not dramatic, so no strong opinion if we should merge that PR or close it. The methods are called very often so the 100M iteration is not totally crazy (2M times in a short profiling session without lot of UI interaction). To look why they are called that often would be another task, but I assume a big part are Comparators and that sums up quickly at list sorting operations.




-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4955#issuecomment-745302802
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20201215/c1bdc0bb/attachment.htm>


More information about the bisq-github mailing list