Old problem with performance

Weed resume755 at mail.ru
Sun Feb 8 18:38:52 PST 2009


Christopher Wright пишет:
> Weed wrote:
>> (Has started here:
>> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=81359)
>>
>>
>> To me still does not give rest performance of classes (in comparison
>> with C++ or with D structs)
> 
> On my system, your struct example averaged 0.36 seconds, and your class
> example averaged 0.38 seconds.
> 
> Your benchmark is flawed in three ways:
> 1. You're timing allocations in the class example. Use opAddAssign to
> avoid it.

Earlier I proved that it is impossible. For example here in such expression:
==============
space_ship_1.calculatePathTo("Moon").getCheckpoint(3).getCoords;

In this example we create a temporary class "path", create temporary
class "checkpoint" and we take coords of checkpoint of this path. It is
not expedient to us to store all this path and checkpoint because it is
vary.
==============

> 2. You're passing large structs in the struct example. Use ref to avoid it.
> 3. c1 is never assigned to, so c1 + c1 + c1 is moved outside the loop.
> The assignment has no side effect, so the loop is optimized out. Replace
> "c1 + c1 + c1" with "c1 + c2 + c1", for instance, and the struct example
> takes 20 seconds rather than 0.36.

Really, it has a little affected. Thanks!



More information about the Digitalmars-d mailing list