I
ilkinulas
Hi,
two functions test1 and test2 does the same thing but test2 performs
nearly 20 times better than test1. JVM is unable to optimize the code
in test1. is there a way to tell the java virtual machine to do this
kind of optimization at compile time or runtime?
NOTE : we are using Log4J and java version "1.4.2_02"
private static final Logger log = Logger.getLogger(DebugTest.class);
--------------------------------------------------------------------------
public void test1() {
for (int i = 0; i < 10000000;i++) {
String s ="test"+i;
if(log.isDebugEnabled()) {
log.debug(s);
}
}
}
public void test2() {
for (int i = 0; i < 10000000;i++) {
if(log.isDebugEnabled()) {
String s ="test"+i;
log.debug(s);
}
}
}
--------------------------------------------------------------------------
two functions test1 and test2 does the same thing but test2 performs
nearly 20 times better than test1. JVM is unable to optimize the code
in test1. is there a way to tell the java virtual machine to do this
kind of optimization at compile time or runtime?
NOTE : we are using Log4J and java version "1.4.2_02"
private static final Logger log = Logger.getLogger(DebugTest.class);
--------------------------------------------------------------------------
public void test1() {
for (int i = 0; i < 10000000;i++) {
String s ="test"+i;
if(log.isDebugEnabled()) {
log.debug(s);
}
}
}
public void test2() {
for (int i = 0; i < 10000000;i++) {
if(log.isDebugEnabled()) {
String s ="test"+i;
log.debug(s);
}
}
}
--------------------------------------------------------------------------