Re: Do you use a garbage collector (java vs c++ difference in "new")
On Sat, 12 Apr 2008 01:08:13 -0700 (PDT), Mirek Fidler
<cxl@ntllib.org> wrote:
the last U++ version was around 1700ms this one 7671 ms
Ah, you have missed important fact that we are now doing completely
different benchmark :) One that will keep some live data in the
memory, this maybe exhibiting the real costs of GC...
Java -server -Xms64m Test
Time: 17219 ms
hmm ..that's twice slower than U++ version. Changing some flags.
Java -server -Xms128m -Xmx128m Test
Time: 11344 ms
closer now :) Chamging more flags
Java -server -Xms256m -Xmx256m Test
Time: 6188 ms
I win :))
Changing flags more...
Java -server -Xms512m -Xmx512m Test
I am two times faster than U++ :)
--- java version ---
public final class Test
{
Test left;
Test right;
static Test CreateTree(int n)
{
if(n <= 0)
return null;
Test t = new Test();
t.left = CreateTree(n - 1);
t.right = CreateTree(n - 1);
return t;
}
public static void main( String[] arg )
{
long start = System.currentTimeMillis();
for(int i = 0; i < 100; i++)
CreateTree(20);
long end = System.currentTimeMillis();
System.out.println( "Time: " + ( end - start ) + " ms" );
}
}