[bisq-network/bisq] Optimize some hotspots (#3214)

Florian Reimair notifications at github.com
Fri Sep 6 12:25:50 UTC 2019


I just played around with numbers a bit and there came a surprising result. But please take these results with a pinch of salt (there might be some caching involved).

- I placed a breakpoint in `Connection.java:763'
- used the [Evaluate]-Tool of IntelliJ to execute:
```
long start = System.nanoTime();
for(int i = 0; i < 1000; i++)
	log.debug("size=" + size + "object=" + Utilities.toTruncatedString(proto, 100));
System.err.println((System.nanoTime()-start)/1000);
start = System.nanoTime();
for(int i = 0; i < 1000; i++)
	log.debug("size={}; object={}", size, Utilities.toTruncatedString(proto, 100));
System.err.println((System.nanoTime()-start)/1000);
start = System.nanoTime();
for(int i = 0; i < 1000; i++)
   if (log.isDebugEnabled())
       log.debug("size={}; object={}", size, Utilities.toTruncatedString(proto, 100));
System.err.println((System.nanoTime()-start)/1000);
```
and
```
long start = System.nanoTime();
for(int i = 0; i < 1000; i++)
    log.debug("size=" + size);
System.err.println((System.nanoTime()-start)/1000);
start = System.nanoTime();
for(int i = 0; i < 1000; i++)
    log.debug("size={}", size);
System.err.println((System.nanoTime()-start)/1000);
start = System.nanoTime();
for(int i = 0; i < 1000; i++)
   if (log.isDebugEnabled())
       log.debug("size={}", size);
System.err.println((System.nanoTime()-start)/1000);
```
and
```
long start = System.nanoTime();
for(int i = 0; i < 1000; i++)
    log.debug("classname=" + this.getClass().getSimpleName());
System.err.println((System.nanoTime()-start)/1000);
start = System.nanoTime();
for(int i = 0; i < 1000; i++)
    log.debug("classname={}", this.getClass().getSimpleName());
System.err.println((System.nanoTime()-start)/1000);
start = System.nanoTime();
for(int i = 0; i < 1000; i++)
	if(log.isDebugEnabled())
    	log.debug("classname={}", this.getClass().getSimpleName());
System.err.println((System.nanoTime()-start)/1000);
- and here comes the somewhat surprising result:
![Screenshot from 2019-09-06 14-21-31](https://user-images.githubusercontent.com/1070734/64427728-2b41cf00-d0b2-11e9-8f8e-24161dad47eb.png)



-- 
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/3214#issuecomment-528834178
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20190906/c3479006/attachment.html>


More information about the bisq-github mailing list