January 31, 2004
I'll have more to say when I've had a chance to dig into the code, but the first thing I can say is that you need to make a choice as to whether to measure (i) the cost of an app such as the one you have, including startup and shutdown costs, and represent the results as such, rather than as a comparison of memory allocation times, or (ii) you need to ensure that you do "warm-up" loops so that you're measuring the memory infrastructures as they are likely to behave in a real system someway through its lifetime, rather than just the performance of a newly initiated application.

Other things:

You appear to measure the elapsed time for a single execution with the program. Do you then do several runs and take averages? Do you discard a proportion of the lowest and highest times?

If you're interested in measuring the total app time, then consider using the ptime utility - from http://synesis.com.au/r_systools.html - to control execution, elide extreme cases and calculate averages.

If you're interested purely in the memory time, then you should include warmups in the app, and calculate averages of the resultant normal-time loops.

If you don't take these measures, then how do we know whether the memory times you report reflect the fundamentals of the languages' memory allocation, or the OS virtual memory? They may even be reflective of the order in which you ran your test programs.

Of course, you may have taken some/all of these measures, and just not mentioned it in your post. If that's the case, can you let us know how it was done?

Cheers

Matthew


"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvcl8a$19hv$1@digitaldaemon.com...
> Matthew wrote:
> > Please post your code
> >
> > "Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvc49s$dej$1@digitaldaemon.com...
> >
> >>Hello
> >>
> >>    Nice language, I think it will have a bright future if it
> >>performance   is near C++.
> >>
> >>    I'm new to D and I'm trying to benchmark a small application (a GLR
> >>parser) with C++, Java and D.
> >>
> >>    First at all a question, it is possible to use bulk class
> >>allocation?. If I'm not wrong MyClass[] mc = new MyClass[num] allocates (in C terms) an array of pointers to classes instead an array of
classes.
> >>
> >>    Since the application expends half of the time allocating objects
> >>(in the java version) I create a test to compare object allocation
> >>performance between languages.
> >>
> >>The test allocates 13 arrays with 64000 elements for each one of four struct types, the allocated memory in java is around 124 MB. The times used to run the test are
> >>
> >>    C++ 109 ms (including initialization)
> >>    D   400 ms
> >>    Java 1050 ms (objects allocated one by one since there is not bulk
> >>                    allocation)
> >>
> >>    Is this a good result?, I expect D times will be slightly over C++
> >>ones but 4x seems too much.
> >>
> >>    The code is available for anyone who wants to review it, but it is a
> >>very simple one, only struct definition and array allocation.
> >>
> >>Regards
> >>Blas Rodriguez Somoza
> >
> >
> >
>
> I make some more tests and I found some interesting results.
>
> Instead of allocating a element 800000 array, I try allocating
> A.- in one array
> B.- in 8 arrays (100000)
> C.- in 13 arrays (12*64000 + 32000)
>
> The resulting times (A/B/C) are:
>
> C++  - 171 / 171 / 171  ms
> D    - 344 / 593 / 484  ms (arrays of pointers as **)
>       - 547 / 1078/ 1000 ms (arrays of pointers as *[])
> Java - 1703 ms (only tested in one array)
>
> It seems C++ gives a constant performance for any array size whether D performs worse with more arrays and apparently with no power of 2 sized arrays
>
> Hope it helps.
>
> Regards
> Blas Rodriguez Somoza
>


January 31, 2004
Good advice, Matthew.

Benchmarking is a very complicated endeavor, fraught with pitfalls to trap the unwary into thinking they have some results, when actually they've been measuring something completely different such as how the order of running the tests affects the memory cache.  Profiling (finding the slow parts of an app) has many similar, but different, issues.

The bottom line is, if you don't know how to profile or benchmark, don't advertise that you do;  it's just misleading to yourself and others.

Sean

"Matthew" <matthew.hat@stlsoft.dot.org> wrote in message news:bvg4kv$114g$1@digitaldaemon.com...
> I'll have more to say when I've had a chance to dig into the code, but the first thing I can say is that you need to make a choice as to whether to measure (i) the cost of an app such as the one you have, including startup and shutdown costs, and represent the results as such, rather than as a comparison of memory allocation times, or (ii) you need to ensure that you do "warm-up" loops so that you're measuring the memory infrastructures as they are likely to behave in a real system someway through its lifetime, rather than just the performance of a newly initiated application.
>
> Other things:
>
> You appear to measure the elapsed time for a single execution with the program. Do you then do several runs and take averages? Do you discard a proportion of the lowest and highest times?
>
> If you're interested in measuring the total app time, then consider using the ptime utility - from http://synesis.com.au/r_systools.html - to
control
> execution, elide extreme cases and calculate averages.
>
> If you're interested purely in the memory time, then you should include warmups in the app, and calculate averages of the resultant normal-time loops.
>
> If you don't take these measures, then how do we know whether the memory times you report reflect the fundamentals of the languages' memory allocation, or the OS virtual memory? They may even be reflective of the order in which you ran your test programs.
>
> Of course, you may have taken some/all of these measures, and just not mentioned it in your post. If that's the case, can you let us know how it was done?
>
> Cheers
>
> Matthew
>
>
> "Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvcl8a$19hv$1@digitaldaemon.com...
> > Matthew wrote:
> > > Please post your code
> > >
> > > "Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvc49s$dej$1@digitaldaemon.com...
> > >
> > >>Hello
> > >>
> > >>    Nice language, I think it will have a bright future if it
> > >>performance   is near C++.
> > >>
> > >>    I'm new to D and I'm trying to benchmark a small application (a
GLR
> > >>parser) with C++, Java and D.
> > >>
> > >>    First at all a question, it is possible to use bulk class
> > >>allocation?. If I'm not wrong MyClass[] mc = new MyClass[num]
allocates
> > >>(in C terms) an array of pointers to classes instead an array of
> classes.
> > >>
> > >>    Since the application expends half of the time allocating objects
> > >>(in the java version) I create a test to compare object allocation
> > >>performance between languages.
> > >>
> > >>The test allocates 13 arrays with 64000 elements for each one of four struct types, the allocated memory in java is around 124 MB. The times used to run the test are
> > >>
> > >>    C++ 109 ms (including initialization)
> > >>    D   400 ms
> > >>    Java 1050 ms (objects allocated one by one since there is not bulk
> > >>                    allocation)
> > >>
> > >>    Is this a good result?, I expect D times will be slightly over C++
> > >>ones but 4x seems too much.
> > >>
> > >>    The code is available for anyone who wants to review it, but it is
a
> > >>very simple one, only struct definition and array allocation.
> > >>
> > >>Regards
> > >>Blas Rodriguez Somoza
> > >
> > >
> > >
> >
> > I make some more tests and I found some interesting results.
> >
> > Instead of allocating a element 800000 array, I try allocating
> > A.- in one array
> > B.- in 8 arrays (100000)
> > C.- in 13 arrays (12*64000 + 32000)
> >
> > The resulting times (A/B/C) are:
> >
> > C++  - 171 / 171 / 171  ms
> > D    - 344 / 593 / 484  ms (arrays of pointers as **)
> >       - 547 / 1078/ 1000 ms (arrays of pointers as *[])
> > Java - 1703 ms (only tested in one array)
> >
> > It seems C++ gives a constant performance for any array size whether D performs worse with more arrays and apparently with no power of 2 sized arrays
> >
> > Hope it helps.
> >
> > Regards
> > Blas Rodriguez Somoza
> >
>
>


February 01, 2004
Phill wrote:
> I didnt even look at the D code, just the C++ and
> Java code.
> I dont know how you can seriously say that they
> are equivalent code.
> 

What are the differences (excluding of course java don't allow bulk allocation) according to you?

Anyway the question is about C++ and D.

Regards
Blas Rodriguez Somoza

> Phill.
> 
> "Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message
> news:bvcl8a$19hv$1@digitaldaemon.com...
> 
>>Matthew wrote:
>>
>>>Please post your code
>>>
>>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message
>>>news:bvc49s$dej$1@digitaldaemon.com...
>>>
>>>
>>>>Hello
>>>>
>>>>   Nice language, I think it will have a bright future if it
>>>>performance   is near C++.
>>>>
>>>>   I'm new to D and I'm trying to benchmark a small application (a GLR
>>>>parser) with C++, Java and D.
>>>>
>>>>   First at all a question, it is possible to use bulk class
>>>>allocation?. If I'm not wrong MyClass[] mc = new MyClass[num] allocates
>>>>(in C terms) an array of pointers to classes instead an array of
> 
> classes.
> 
>>>>   Since the application expends half of the time allocating objects
>>>>(in the java version) I create a test to compare object allocation
>>>>performance between languages.
>>>>
>>>>The test allocates 13 arrays with 64000 elements for each one of four
>>>>struct types, the allocated memory in java is around 124 MB. The times
>>>>used to run the test are
>>>>
>>>>   C++ 109 ms (including initialization)
>>>>   D   400 ms
>>>>   Java 1050 ms (objects allocated one by one since there is not bulk
>>>>                   allocation)
>>>>
>>>>   Is this a good result?, I expect D times will be slightly over C++
>>>>ones but 4x seems too much.
>>>>
>>>>   The code is available for anyone who wants to review it, but it is a
>>>>very simple one, only struct definition and array allocation.
>>>>
>>>>Regards
>>>>Blas Rodriguez Somoza
>>>
>>>
>>>
>>I make some more tests and I found some interesting results.
>>
>>Instead of allocating a element 800000 array, I try allocating
>>A.- in one array
>>B.- in 8 arrays (100000)
>>C.- in 13 arrays (12*64000 + 32000)
>>
>>The resulting times (A/B/C) are:
>>
>>C++  - 171 / 171 / 171  ms
>>D    - 344 / 593 / 484  ms (arrays of pointers as **)
>>      - 547 / 1078/ 1000 ms (arrays of pointers as *[])
>>Java - 1703 ms (only tested in one array)
>>
>>It seems C++ gives a constant performance for any array size whether D
>>performs worse with more arrays and apparently with no power of 2 sized
>>arrays
>>
>>Hope it helps.
>>
>>Regards
>>Blas Rodriguez Somoza
>>
> 
> 
> 
February 01, 2004
Matthew wrote:

> I'll have more to say when I've had a chance to dig into the code, but the
> first thing I can say is that you need to make a choice as to whether to
> measure (i) the cost of an app such as the one you have, including startup
> and shutdown costs, and represent the results as such, rather than as a
> comparison of memory allocation times, or (ii) you need to ensure that you
> do "warm-up" loops so that you're measuring the memory infrastructures as
> they are likely to behave in a real system someway through its lifetime,
> rather than just the performance of a newly initiated application.
> 

The application is GLR parser, and as I plan to use it its livetime is one execution and a half of the time is expended in memory allocation. The number of objects are more or less the number of objects in the largest example I use to test the parser.

> Other things:
> 
> You appear to measure the elapsed time for a single execution with the
> program. Do you then do several runs and take averages? Do you discard a
> proportion of the lowest and highest times?
> 

The executions are in a controled environment and excluding Java which have some variations, the C++ and D have less than 1% differences between executions.

> If you're interested in measuring the total app time, then consider using
> the ptime utility - from http://synesis.com.au/r_systools.html - to control
> execution, elide extreme cases and calculate averages.
> 
> If you're interested purely in the memory time, then you should include
> warmups in the app, and calculate averages of the resultant normal-time
> loops.
> 
> If you don't take these measures, then how do we know whether the memory
> times you report reflect the fundamentals of the languages' memory
> allocation, or the OS virtual memory? They may even be reflective of the
> order in which you ran your test programs.
> 

In this case the test should include in its result all those things. I'm trying to measure the performance with a OS (windows) and a language/compiler (C++ mingw/gcc 3.3.2, D and Java(sun jdk 1.4.2). In this case I don't want/need to analyse the reasons of the performance results.

> Of course, you may have taken some/all of these measures, and just not
> mentioned it in your post. If that's the case, can you let us know how it
> was done?
> 
> Cheers
> 
> Matthew
> 
> 
> "Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message
> news:bvcl8a$19hv$1@digitaldaemon.com...
> 
>>Matthew wrote:
>>
>>>Please post your code
>>>
>>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message
>>>news:bvc49s$dej$1@digitaldaemon.com...
>>>
>>>
>>>>Hello
>>>>
>>>>   Nice language, I think it will have a bright future if it
>>>>performance   is near C++.
>>>>
>>>>   I'm new to D and I'm trying to benchmark a small application (a GLR
>>>>parser) with C++, Java and D.
>>>>
>>>>   First at all a question, it is possible to use bulk class
>>>>allocation?. If I'm not wrong MyClass[] mc = new MyClass[num] allocates
>>>>(in C terms) an array of pointers to classes instead an array of
> 
> classes.
> 
>>>>   Since the application expends half of the time allocating objects
>>>>(in the java version) I create a test to compare object allocation
>>>>performance between languages.
>>>>
>>>>The test allocates 13 arrays with 64000 elements for each one of four
>>>>struct types, the allocated memory in java is around 124 MB. The times
>>>>used to run the test are
>>>>
>>>>   C++ 109 ms (including initialization)
>>>>   D   400 ms
>>>>   Java 1050 ms (objects allocated one by one since there is not bulk
>>>>                   allocation)
>>>>
>>>>   Is this a good result?, I expect D times will be slightly over C++
>>>>ones but 4x seems too much.
>>>>
>>>>   The code is available for anyone who wants to review it, but it is a
>>>>very simple one, only struct definition and array allocation.
>>>>
>>>>Regards
>>>>Blas Rodriguez Somoza
>>>
>>>
>>>
>>I make some more tests and I found some interesting results.
>>
>>Instead of allocating a element 800000 array, I try allocating
>>A.- in one array
>>B.- in 8 arrays (100000)
>>C.- in 13 arrays (12*64000 + 32000)
>>
>>The resulting times (A/B/C) are:
>>
>>C++  - 171 / 171 / 171  ms
>>D    - 344 / 593 / 484  ms (arrays of pointers as **)
>>      - 547 / 1078/ 1000 ms (arrays of pointers as *[])
>>Java - 1703 ms (only tested in one array)
>>
>>It seems C++ gives a constant performance for any array size whether D
>>performs worse with more arrays and apparently with no power of 2 sized
>>arrays
>>
>>Hope it helps.
>>
>>Regards
>>Blas Rodriguez Somoza
>>
> 
> 
> 
February 01, 2004
Sean L. Palmer wrote:

> Good advice, Matthew.
> 
> Benchmarking is a very complicated endeavor, fraught with pitfalls to trap
> the unwary into thinking they have some results, when actually they've been
> measuring something completely different such as how the order of running
> the tests affects the memory cache.  Profiling (finding the slow parts of an
> app) has many similar, but different, issues.
> 
> The bottom line is, if you don't know how to profile or benchmark, don't
> advertise that you do;  it's just misleading to yourself and others.
> 
> Sean
> 

Until now it seems nobody excluding Jon give any advice about the results or argue the results are wrong with reasons.

Perhaps I have some strange habbits but when I post this question and data I expect some advice and not a flame war.

At least in other projects in the net this is the usual way to work when someone make a question and give code and numbers about it.

I know how to profile/benchmark and I did it in several os and languages in my previous 22 years working in this business. (F.I after my work in the Firebird jdbc driver it performs some others of magnitude better).


> "Matthew" <matthew.hat@stlsoft.dot.org> wrote in message
> news:bvg4kv$114g$1@digitaldaemon.com...
> 
>>I'll have more to say when I've had a chance to dig into the code, but the
>>first thing I can say is that you need to make a choice as to whether to
>>measure (i) the cost of an app such as the one you have, including startup
>>and shutdown costs, and represent the results as such, rather than as a
>>comparison of memory allocation times, or (ii) you need to ensure that you
>>do "warm-up" loops so that you're measuring the memory infrastructures as
>>they are likely to behave in a real system someway through its lifetime,
>>rather than just the performance of a newly initiated application.
>>
>>Other things:
>>
>>You appear to measure the elapsed time for a single execution with the
>>program. Do you then do several runs and take averages? Do you discard a
>>proportion of the lowest and highest times?
>>
>>If you're interested in measuring the total app time, then consider using
>>the ptime utility - from http://synesis.com.au/r_systools.html - to
> 
> control
> 
>>execution, elide extreme cases and calculate averages.
>>
>>If you're interested purely in the memory time, then you should include
>>warmups in the app, and calculate averages of the resultant normal-time
>>loops.
>>
>>If you don't take these measures, then how do we know whether the memory
>>times you report reflect the fundamentals of the languages' memory
>>allocation, or the OS virtual memory? They may even be reflective of the
>>order in which you ran your test programs.
>>
>>Of course, you may have taken some/all of these measures, and just not
>>mentioned it in your post. If that's the case, can you let us know how it
>>was done?
>>
>>Cheers
>>
>>Matthew
>>
>>
>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message
>>news:bvcl8a$19hv$1@digitaldaemon.com...
>>
>>>Matthew wrote:
>>>
>>>>Please post your code
>>>>
>>>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message
>>>>news:bvc49s$dej$1@digitaldaemon.com...
>>>>
>>>>
>>>>>Hello
>>>>>
>>>>>   Nice language, I think it will have a bright future if it
>>>>>performance   is near C++.
>>>>>
>>>>>   I'm new to D and I'm trying to benchmark a small application (a
> 
> GLR
> 
>>>>>parser) with C++, Java and D.
>>>>>
>>>>>   First at all a question, it is possible to use bulk class
>>>>>allocation?. If I'm not wrong MyClass[] mc = new MyClass[num]
> 
> allocates
> 
>>>>>(in C terms) an array of pointers to classes instead an array of
>>
>>classes.
>>
>>>>>   Since the application expends half of the time allocating objects
>>>>>(in the java version) I create a test to compare object allocation
>>>>>performance between languages.
>>>>>
>>>>>The test allocates 13 arrays with 64000 elements for each one of four
>>>>>struct types, the allocated memory in java is around 124 MB. The times
>>>>>used to run the test are
>>>>>
>>>>>   C++ 109 ms (including initialization)
>>>>>   D   400 ms
>>>>>   Java 1050 ms (objects allocated one by one since there is not bulk
>>>>>                   allocation)
>>>>>
>>>>>   Is this a good result?, I expect D times will be slightly over C++
>>>>>ones but 4x seems too much.
>>>>>
>>>>>   The code is available for anyone who wants to review it, but it is
> 
> a
> 
>>>>>very simple one, only struct definition and array allocation.
>>>>>
>>>>>Regards
>>>>>Blas Rodriguez Somoza
>>>>
>>>>
>>>>
>>>I make some more tests and I found some interesting results.
>>>
>>>Instead of allocating a element 800000 array, I try allocating
>>>A.- in one array
>>>B.- in 8 arrays (100000)
>>>C.- in 13 arrays (12*64000 + 32000)
>>>
>>>The resulting times (A/B/C) are:
>>>
>>>C++  - 171 / 171 / 171  ms
>>>D    - 344 / 593 / 484  ms (arrays of pointers as **)
>>>      - 547 / 1078/ 1000 ms (arrays of pointers as *[])
>>>Java - 1703 ms (only tested in one array)
>>>
>>>It seems C++ gives a constant performance for any array size whether D
>>>performs worse with more arrays and apparently with no power of 2 sized
>>>arrays
>>>
>>>Hope it helps.
>>>
>>>Regards
>>>Blas Rodriguez Somoza
>>>
>>
>>
> 
> 
February 01, 2004
"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvhs5s$rkg$1@digitaldaemon.com...
> Sean L. Palmer wrote:
>
> > Good advice, Matthew.
> >
> > Benchmarking is a very complicated endeavor, fraught with pitfalls to
trap
> > the unwary into thinking they have some results, when actually they've
been
> > measuring something completely different such as how the order of
running
> > the tests affects the memory cache.  Profiling (finding the slow parts
of an
> > app) has many similar, but different, issues.
> >
> > The bottom line is, if you don't know how to profile or benchmark, don't advertise that you do;  it's just misleading to yourself and others.
> >
> > Sean
> >
>
> Until now it seems nobody excluding Jon give any advice about the results or argue the results are wrong with reasons.
>
> Perhaps I have some strange habbits but when I post this question and data I expect some advice and not a flame war.

Mate, this isn't a flame war. This is the gentlest NG I've ever encountered, and this thread has been gentle even for this NG. Why don't you profer some performance stats to the Boost NG, and see how it feels to get really flamed?

> At least in other projects in the net this is the usual way to work when someone make a question and give code and numbers about it.
>
> I know how to profile/benchmark and I did it in several os and languages in my previous 22 years working in this business. (F.I after my work in the Firebird jdbc driver it performs some others of magnitude better).

Two things:

1. If you're a highly competent profiler, and you know all the
ramifications, why is it that your post did not give any/enough hints such
that we'd pick up on that?
2. I have to say that, given the look I've had so far at your code, that I
don't see anything to counter the impression described in 1.

I'm sorry if this seems like a personal attack, but I was simply going on your posts and the code.

>
>
> > "Matthew" <matthew.hat@stlsoft.dot.org> wrote in message news:bvg4kv$114g$1@digitaldaemon.com...
> >
> >>I'll have more to say when I've had a chance to dig into the code, but
the
> >>first thing I can say is that you need to make a choice as to whether to measure (i) the cost of an app such as the one you have, including
startup
> >>and shutdown costs, and represent the results as such, rather than as a comparison of memory allocation times, or (ii) you need to ensure that
you
> >>do "warm-up" loops so that you're measuring the memory infrastructures
as
> >>they are likely to behave in a real system someway through its lifetime, rather than just the performance of a newly initiated application.
> >>
> >>Other things:
> >>
> >>You appear to measure the elapsed time for a single execution with the program. Do you then do several runs and take averages? Do you discard a proportion of the lowest and highest times?
> >>
> >>If you're interested in measuring the total app time, then consider
using
> >>the ptime utility - from http://synesis.com.au/r_systools.html - to
> >
> > control
> >
> >>execution, elide extreme cases and calculate averages.
> >>
> >>If you're interested purely in the memory time, then you should include warmups in the app, and calculate averages of the resultant normal-time loops.
> >>
> >>If you don't take these measures, then how do we know whether the memory times you report reflect the fundamentals of the languages' memory allocation, or the OS virtual memory? They may even be reflective of the order in which you ran your test programs.
> >>
> >>Of course, you may have taken some/all of these measures, and just not mentioned it in your post. If that's the case, can you let us know how
it
> >>was done?
> >>
> >>Cheers
> >>
> >>Matthew
> >>
> >>
> >>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvcl8a$19hv$1@digitaldaemon.com...
> >>
> >>>Matthew wrote:
> >>>
> >>>>Please post your code
> >>>>
> >>>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvc49s$dej$1@digitaldaemon.com...
> >>>>
> >>>>
> >>>>>Hello
> >>>>>
> >>>>>   Nice language, I think it will have a bright future if it
> >>>>>performance   is near C++.
> >>>>>
> >>>>>   I'm new to D and I'm trying to benchmark a small application (a
> >
> > GLR
> >
> >>>>>parser) with C++, Java and D.
> >>>>>
> >>>>>   First at all a question, it is possible to use bulk class
> >>>>>allocation?. If I'm not wrong MyClass[] mc = new MyClass[num]
> >
> > allocates
> >
> >>>>>(in C terms) an array of pointers to classes instead an array of
> >>
> >>classes.
> >>
> >>>>>   Since the application expends half of the time allocating objects
> >>>>>(in the java version) I create a test to compare object allocation
> >>>>>performance between languages.
> >>>>>
> >>>>>The test allocates 13 arrays with 64000 elements for each one of four struct types, the allocated memory in java is around 124 MB. The
times
> >>>>>used to run the test are
> >>>>>
> >>>>>   C++ 109 ms (including initialization)
> >>>>>   D   400 ms
> >>>>>   Java 1050 ms (objects allocated one by one since there is not bulk
> >>>>>                   allocation)
> >>>>>
> >>>>>   Is this a good result?, I expect D times will be slightly over C++
> >>>>>ones but 4x seems too much.
> >>>>>
> >>>>>   The code is available for anyone who wants to review it, but it is
> >
> > a
> >
> >>>>>very simple one, only struct definition and array allocation.
> >>>>>
> >>>>>Regards
> >>>>>Blas Rodriguez Somoza
> >>>>
> >>>>
> >>>>
> >>>I make some more tests and I found some interesting results.
> >>>
> >>>Instead of allocating a element 800000 array, I try allocating
> >>>A.- in one array
> >>>B.- in 8 arrays (100000)
> >>>C.- in 13 arrays (12*64000 + 32000)
> >>>
> >>>The resulting times (A/B/C) are:
> >>>
> >>>C++  - 171 / 171 / 171  ms
> >>>D    - 344 / 593 / 484  ms (arrays of pointers as **)
> >>>      - 547 / 1078/ 1000 ms (arrays of pointers as *[])
> >>>Java - 1703 ms (only tested in one array)
> >>>
> >>>It seems C++ gives a constant performance for any array size whether D performs worse with more arrays and apparently with no power of 2 sized arrays
> >>>
> >>>Hope it helps.
> >>>
> >>>Regards
> >>>Blas Rodriguez Somoza
> >>>
> >>
> >>
> >
> >


February 01, 2004
Blas Rodriguez Somoza wrote:

[snip]
> Until now it seems nobody excluding Jon give any advice about the results or argue the results are wrong with reasons.
> 
> Perhaps I have some strange habbits but when I post this question and data I expect some advice and not a flame war.

I agree, you're being mistreated.  Your tests show a significant difference.  It's like whining for a recount when the vote shows 80% to 20%.

I would expect that it is mostly in the garbage collector.  When making an allocation, if it runs out of memory it has allocated it will run a full garbage collection (the relevant code is in "/dmd/src/phobos/internal/gc/gcx.d").  I believe you said before that you were getting exponential increases in time as you added more allocations, and that would account for that.  I don't know much about the garbage collector so I can't speculate any further.

This could also partially be due to the contracts in Phobos, which often have heavy redundancy, such as how array.dup uses a memcmp to ensure that the result is correct.  I don't know if there are burdensome contracts involved with allocation.  One way to be sure this is not a factor is to recompile Phobos with the "-release" compiler switch provided, as well as your own code.

The Java performance is actually really impressive.  I doubt DMD would be able to compare with it if it performed the same, rather than similar, operations.  In fact, I suspect Java might even out-perform your C++ compiler in a same-operation comparison.

[snip]

February 01, 2004
"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvhp5f$n10$1@digitaldaemon.com...
> Phill wrote:
> > I didnt even look at the D code, just the C++ and
> > Java code.
> > I dont know how you can seriously say that they
> > are equivalent code.
> >
>
> What are the differences (excluding of course java don't allow bulk
> allocation) according to you?

At a quick glance, if im not wrong you make 800000 Objects in the Java code compared to 64000 in the C++ code.

Phill.


>
> Anyway the question is about C++ and D.
>
> Regards
> Blas Rodriguez Somoza
>
> > Phill.
> >
> > "Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvcl8a$19hv$1@digitaldaemon.com...
> >
> >>Matthew wrote:
> >>
> >>>Please post your code
> >>>
> >>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvc49s$dej$1@digitaldaemon.com...
> >>>
> >>>
> >>>>Hello
> >>>>
> >>>>   Nice language, I think it will have a bright future if it
> >>>>performance   is near C++.
> >>>>
> >>>>   I'm new to D and I'm trying to benchmark a small application (a GLR
> >>>>parser) with C++, Java and D.
> >>>>
> >>>>   First at all a question, it is possible to use bulk class
> >>>>allocation?. If I'm not wrong MyClass[] mc = new MyClass[num]
allocates
> >>>>(in C terms) an array of pointers to classes instead an array of
> >
> > classes.
> >
> >>>>   Since the application expends half of the time allocating objects
> >>>>(in the java version) I create a test to compare object allocation
> >>>>performance between languages.
> >>>>
> >>>>The test allocates 13 arrays with 64000 elements for each one of four struct types, the allocated memory in java is around 124 MB. The times used to run the test are
> >>>>
> >>>>   C++ 109 ms (including initialization)
> >>>>   D   400 ms
> >>>>   Java 1050 ms (objects allocated one by one since there is not bulk
> >>>>                   allocation)
> >>>>
> >>>>   Is this a good result?, I expect D times will be slightly over C++
> >>>>ones but 4x seems too much.
> >>>>
> >>>>   The code is available for anyone who wants to review it, but it is
a
> >>>>very simple one, only struct definition and array allocation.
> >>>>
> >>>>Regards
> >>>>Blas Rodriguez Somoza
> >>>
> >>>
> >>>
> >>I make some more tests and I found some interesting results.
> >>
> >>Instead of allocating a element 800000 array, I try allocating
> >>A.- in one array
> >>B.- in 8 arrays (100000)
> >>C.- in 13 arrays (12*64000 + 32000)
> >>
> >>The resulting times (A/B/C) are:
> >>
> >>C++  - 171 / 171 / 171  ms
> >>D    - 344 / 593 / 484  ms (arrays of pointers as **)
> >>      - 547 / 1078/ 1000 ms (arrays of pointers as *[])
> >>Java - 1703 ms (only tested in one array)
> >>
> >>It seems C++ gives a constant performance for any array size whether D performs worse with more arrays and apparently with no power of 2 sized arrays
> >>
> >>Hope it helps.
> >>
> >>Regards
> >>Blas Rodriguez Somoza
> >>
> >
> >
> >


February 01, 2004
But at a longer glance I see my statement is not
correct :o)) my apologies.

One thing that I noticed is that I cant even run
the Java code because of :
Exception in thread "main" java.lang.OutOfMemoryError

Whereas I can run the C++ version easily.

Phill.

"Phill" <phill@pacific.net.au> wrote in message news:bvi7q1$1ejb$1@digitaldaemon.com...
>
> "Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvhp5f$n10$1@digitaldaemon.com...
> > Phill wrote:
> > > I didnt even look at the D code, just the C++ and
> > > Java code.
> > > I dont know how you can seriously say that they
> > > are equivalent code.
> > >
> >
> > What are the differences (excluding of course java don't allow bulk
> > allocation) according to you?
>
> At a quick glance, if im not wrong you make 800000 Objects in the Java code compared to 64000 in the C++ code.
>
> Phill.
>
>
> >
> > Anyway the question is about C++ and D.
> >
> > Regards
> > Blas Rodriguez Somoza
> >
> > > Phill.
> > >
> > > "Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvcl8a$19hv$1@digitaldaemon.com...
> > >
> > >>Matthew wrote:
> > >>
> > >>>Please post your code
> > >>>
> > >>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message news:bvc49s$dej$1@digitaldaemon.com...
> > >>>
> > >>>
> > >>>>Hello
> > >>>>
> > >>>>   Nice language, I think it will have a bright future if it
> > >>>>performance   is near C++.
> > >>>>
> > >>>>   I'm new to D and I'm trying to benchmark a small application (a
GLR
> > >>>>parser) with C++, Java and D.
> > >>>>
> > >>>>   First at all a question, it is possible to use bulk class
> > >>>>allocation?. If I'm not wrong MyClass[] mc = new MyClass[num]
> allocates
> > >>>>(in C terms) an array of pointers to classes instead an array of
> > >
> > > classes.
> > >
> > >>>>   Since the application expends half of the time allocating objects
> > >>>>(in the java version) I create a test to compare object allocation
> > >>>>performance between languages.
> > >>>>
> > >>>>The test allocates 13 arrays with 64000 elements for each one of
four
> > >>>>struct types, the allocated memory in java is around 124 MB. The
times
> > >>>>used to run the test are
> > >>>>
> > >>>>   C++ 109 ms (including initialization)
> > >>>>   D   400 ms
> > >>>>   Java 1050 ms (objects allocated one by one since there is not
bulk
> > >>>>                   allocation)
> > >>>>
> > >>>>   Is this a good result?, I expect D times will be slightly over
C++
> > >>>>ones but 4x seems too much.
> > >>>>
> > >>>>   The code is available for anyone who wants to review it, but it
is
> a
> > >>>>very simple one, only struct definition and array allocation.
> > >>>>
> > >>>>Regards
> > >>>>Blas Rodriguez Somoza
> > >>>
> > >>>
> > >>>
> > >>I make some more tests and I found some interesting results.
> > >>
> > >>Instead of allocating a element 800000 array, I try allocating
> > >>A.- in one array
> > >>B.- in 8 arrays (100000)
> > >>C.- in 13 arrays (12*64000 + 32000)
> > >>
> > >>The resulting times (A/B/C) are:
> > >>
> > >>C++  - 171 / 171 / 171  ms
> > >>D    - 344 / 593 / 484  ms (arrays of pointers as **)
> > >>      - 547 / 1078/ 1000 ms (arrays of pointers as *[])
> > >>Java - 1703 ms (only tested in one array)
> > >>
> > >>It seems C++ gives a constant performance for any array size whether D performs worse with more arrays and apparently with no power of 2
sized
> > >>arrays
> > >>
> > >>Hope it helps.
> > >>
> > >>Regards
> > >>Blas Rodriguez Somoza
> > >>
> > >
> > >
> > >
>
>


February 01, 2004
Phill wrote:
> But at a longer glance I see my statement is not
> correct :o)) my apologies.
> 
> One thing that I noticed is that I cant even run
> the Java code because of :
> Exception in thread "main" java.lang.OutOfMemoryError
> 
> Whereas I can run the C++ version easily.
> 

To run the java version you need to use more memory than the default max. Try with

java -Xms128M -Xmx128M examples.pruebaAllocate

Regards
Blas Rodriguez Somoza

> Phill.
> 
> "Phill" <phill@pacific.net.au> wrote in message
> news:bvi7q1$1ejb$1@digitaldaemon.com...
> 
>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message
>>news:bvhp5f$n10$1@digitaldaemon.com...
>>
>>>Phill wrote:
>>>
>>>>I didnt even look at the D code, just the C++ and
>>>>Java code.
>>>>I dont know how you can seriously say that they
>>>>are equivalent code.
>>>>
>>>
>>>What are the differences (excluding of course java don't allow bulk
>>>allocation) according to you?
>>
>>At a quick glance, if im not wrong you make 800000 Objects
>>in the Java code compared to 64000 in the C++ code.
>>
>>Phill.
>>
>>
>>
>>>Anyway the question is about C++ and D.
>>>
>>>Regards
>>>Blas Rodriguez Somoza
>>>
>>>
>>>>Phill.
>>>>
>>>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message
>>>>news:bvcl8a$19hv$1@digitaldaemon.com...
>>>>
>>>>
>>>>>Matthew wrote:
>>>>>
>>>>>
>>>>>>Please post your code
>>>>>>
>>>>>>"Blas Rodriguez Somoza" <blas@puertareal.com> wrote in message
>>>>>>news:bvc49s$dej$1@digitaldaemon.com...
>>>>>>
>>>>>>
>>>>>>
>>>>>>>Hello
>>>>>>>
>>>>>>>  Nice language, I think it will have a bright future if it
>>>>>>>performance   is near C++.
>>>>>>>
>>>>>>>  I'm new to D and I'm trying to benchmark a small application (a
> 
> GLR
> 
>>>>>>>parser) with C++, Java and D.
>>>>>>>
>>>>>>>  First at all a question, it is possible to use bulk class
>>>>>>>allocation?. If I'm not wrong MyClass[] mc = new MyClass[num]
>>
>>allocates
>>
>>>>>>>(in C terms) an array of pointers to classes instead an array of
>>>>
>>>>classes.
>>>>
>>>>
>>>>>>>  Since the application expends half of the time allocating objects
>>>>>>>(in the java version) I create a test to compare object allocation
>>>>>>>performance between languages.
>>>>>>>
>>>>>>>The test allocates 13 arrays with 64000 elements for each one of
> 
> four
> 
>>>>>>>struct types, the allocated memory in java is around 124 MB. The
> 
> times
> 
>>>>>>>used to run the test are
>>>>>>>
>>>>>>>  C++ 109 ms (including initialization)
>>>>>>>  D   400 ms
>>>>>>>  Java 1050 ms (objects allocated one by one since there is not
> 
> bulk
> 
>>>>>>>                  allocation)
>>>>>>>
>>>>>>>  Is this a good result?, I expect D times will be slightly over
> 
> C++
> 
>>>>>>>ones but 4x seems too much.
>>>>>>>
>>>>>>>  The code is available for anyone who wants to review it, but it
> 
> is
> 
>>a
>>
>>>>>>>very simple one, only struct definition and array allocation.
>>>>>>>
>>>>>>>Regards
>>>>>>>Blas Rodriguez Somoza
>>>>>>
>>>>>>
>>>>>>
>>>>>I make some more tests and I found some interesting results.
>>>>>
>>>>>Instead of allocating a element 800000 array, I try allocating
>>>>>A.- in one array
>>>>>B.- in 8 arrays (100000)
>>>>>C.- in 13 arrays (12*64000 + 32000)
>>>>>
>>>>>The resulting times (A/B/C) are:
>>>>>
>>>>>C++  - 171 / 171 / 171  ms
>>>>>D    - 344 / 593 / 484  ms (arrays of pointers as **)
>>>>>     - 547 / 1078/ 1000 ms (arrays of pointers as *[])
>>>>>Java - 1703 ms (only tested in one array)
>>>>>
>>>>>It seems C++ gives a constant performance for any array size whether D
>>>>>performs worse with more arrays and apparently with no power of 2
> 
> sized
> 
>>>>>arrays
>>>>>
>>>>>Hope it helps.
>>>>>
>>>>>Regards
>>>>>Blas Rodriguez Somoza
>>>>>
>>>>
>>>>
>>>>
>>
> 
>