Thread overview | |||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 29, 2004 classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
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 |
January 29, 2004 Re: classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Blas Rodriguez Somoza | Go to: http://www.digitalmars.com/d/memory.html#stackclass Here you can see an example of using a custom allocation routine with a class. -eye Blas Rodriguez Somoza wrote: > 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 |
January 29, 2004 Re: classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Blas Rodriguez Somoza | MyClass[] mc = new MyClass[num] in D that means mc is a dynamic array, and is initialised with a dynamic array of num MyClass objects In article <bvc49s$dej$1@digitaldaemon.com>, Blas Rodriguez Somoza says... > >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 |
January 30, 2004 Re: classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Blas Rodriguez Somoza | 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 |
January 30, 2004 Re: classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Attachments: | 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 30, 2004 Re: classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Blas Rodriguez Somoza | inline Blas Rodriguez Somoza wrote: > Matthew wrote: > >> Please post your code >> > > 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 In D coding for performance can be a little different then C++. You can't compare apples to oranges. So please post your code (C++, D) code so we can give you some performance pointers. Otherwise we have to take this with a pinch of salt. -- -Anderson: http://badmama.com.au/~anderson/ |
January 30, 2004 Re: classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | J Anderson wrote:
> inline
>
> Blas Rodriguez Somoza wrote:
>
>> Matthew wrote:
>>
>>> Please post your code
>>>
>>
>> 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
>
>
>
> In D coding for performance can be a little different then C++. You can't compare apples to oranges. So please post your code (C++, D) code so we can give you some performance pointers. Otherwise we have to take this with a pinch of salt.
>
The code is the message you answer, for C++ D and Java.
I don't try to make any optimization work, I only try to compare the standard allocation in each of the languages. Anyway the code is so simple that don't seem it can be optimized too much.
Regards
Blas Rodriguez Somoza
|
January 30, 2004 Re: classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Blas Rodriguez Somoza | Blas Rodriguez Somoza wrote: > J Anderson wrote: > >> inline >> >> Blas Rodriguez Somoza wrote: >> >>> Matthew wrote: >>> >>>> Please post your code >>>> >>> >>> 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 >> >> >> >> >> In D coding for performance can be a little different then C++. You can't compare apples to oranges. So please post your code (C++, D) code so we can give you some performance pointers. Otherwise we have to take this with a pinch of salt. >> > > The code is the message you answer, for C++ D and Java. > > I don't try to make any optimization work, I only try to compare the standard allocation in each of the languages. Anyway the code is so simple that don't seem it can be optimized too much. > > Regards > Blas Rodriguez Somoza Sorry. I my newsgroup program stuffed up (attachment was missing). Your right. -- -Anderson: http://badmama.com.au/~anderson/ |
January 31, 2004 Re: classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Blas Rodriguez Somoza | Blas Rodriguez Somoza wrote: > 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. Aside from the fact that the D compiler is still beta and doesn't feature the same optimizations, I think its worth mentioning that the D runtime is more complex (garbage collection, etc.) and this probably accounts for some of the difference. I'm not sure if the D code is 4x slower than the C++, or merely takes 300 ms longer at the start of the program, but the latter behavior seems likely to me based on what other people have stated on the ng concerning D's performance. -Jon > > 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 |
January 31, 2004 Re: classes, structs and allocation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Blas Rodriguez Somoza | 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. 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 > |
Copyright © 1999-2021 by the D Language Foundation