J
Jan Burse
Dear All,
I just wonder wether modern JIT do optimize
Code of the following form:
Bla[] bla = new Bla[n];
for (int i=0; i<n; i++) {
bla = new Bla();
}
When I use the above in my code, my application
spends 8800 ms in the benchmark I have.
When I then change the code to:
Bla[] bla = new Bla[n];
...
if (bla==null)
bla = new Bla();
..
So instead of allocating all elements at once,
I will allocate them on demand in the subsequent
flow of my application.
When I use the above in my code, my application
now suddently sends 9600 ms in the benchmark
I have.
So I wonder whether eventually the JIT has
a way to detect the bulk allocate of the first
version and transform it into something more
efficient than my lazy allocation.
Any clues?
Bye
I just wonder wether modern JIT do optimize
Code of the following form:
Bla[] bla = new Bla[n];
for (int i=0; i<n; i++) {
bla = new Bla();
}
When I use the above in my code, my application
spends 8800 ms in the benchmark I have.
When I then change the code to:
Bla[] bla = new Bla[n];
...
if (bla==null)
bla = new Bla();
..
So instead of allocating all elements at once,
I will allocate them on demand in the subsequent
flow of my application.
When I use the above in my code, my application
now suddently sends 9600 ms in the benchmark
I have.
So I wonder whether eventually the JIT has
a way to detect the bulk allocate of the first
version and transform it into something more
efficient than my lazy allocation.
Any clues?
Bye