Calculating secondary structure of 4hhb 10000 times takes 589 seconds on my machine. If the following two lines are commented out, it takes 34 seconds:
|
logger.debug(" cccc: " + one.getResidueNumber() + |
|
" " + one.getPDBName() + " " +two.getResidueNumber()+ |
|
" " + two.getPDBName() + String.format(" O ("+ |
|
O.getPDBserial()+")..N ("+ N.getPDBserial()+ |
|
"):%4.1f | ho:%4.1f - hc:%4.1f + nc:%4.1f - no:%4.1f ", |
|
dno,dho,dhc,dnc,dno)); |
|
logger.debug(String.format(" N (%d) O(%d): %4.1f : %4.2f ", |
|
N.getPDBserial(),O.getPDBserial(), (float) dno, energy)); |
The problem is likely to be in the String.format method. Using SLF4J parameterized messages instead ("{}") is much faster, but does not support float formatting to number of decimal places (see https://stackoverflow.com/questions/22720865/formatting-floating-point-numbers-in-slf4j, thanks @josemduarte ).
My suggestion is to go through the logging messages which use string formatting and, if feasible, change them to parameterized messages.
The performance is noticeably affected only if the logging statements are somewhere deep within a loop.
Calculating secondary structure of 4hhb 10000 times takes 589 seconds on my machine. If the following two lines are commented out, it takes 34 seconds:
biojava/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java
Lines 851 to 856 in 8a7b651
biojava/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java
Lines 869 to 870 in 8a7b651
The problem is likely to be in the String.format method. Using SLF4J parameterized messages instead ("{}") is much faster, but does not support float formatting to number of decimal places (see https://stackoverflow.com/questions/22720865/formatting-floating-point-numbers-in-slf4j, thanks @josemduarte ).
My suggestion is to go through the logging messages which use string formatting and, if feasible, change them to parameterized messages.
The performance is noticeably affected only if the logging statements are somewhere deep within a loop.