Woeful performance of D compared to C++

Dave Dave_member at pathlink.com
Thu Jan 18 13:50:27 PST 2007


Bill Lear wrote:
> 
> The rand() call is definitely the most expensive.  When I remove it
> from both the C++ and the D program, the times plummet (to 0.003
> and 0.013 seconds, respectively --- still, however, leaving the D
> program running in 4.3 times that of the C++ program;-).
> 

Yes, but if you make it so that the C++ compiler can't so easily remove the loop, then they are the 
same :)

int main(int argc, char *argv[])
{
     unsigned char doors = 0;
     //const unsigned int n = 100000000;
     unsigned int n = argc > 1 ? atoi(argv[1]) : 10000000;

<IMHO, that's almost always a worthless optimization for "real-world" code and even "good" 
benchmarks :)>.

> 
> Bill
> --
> Bill Lear
> r * e * @ * o * y * a * c * m
> * a * l * z * p * r * . * o *



More information about the Digitalmars-d mailing list