POV-Ray : Newsgroups : povray.off-topic : Interesting performance comparison of C#s and C++'s : Re: Interesting performance comparison of C#s and C++'s Server Time
29 Jul 2024 18:29:09 EDT (-0400)
  Re: Interesting performance comparison of C#s and C++'s  
From: Darren New
Date: 22 Jun 2011 15:05:12
Message: <4e023ce8$1@news.povray.org>
On 6/22/2011 10:44, Warp wrote:
> Invisible<voi### [at] devnull>  wrote:
>> Trouble is, "typical" isn't very well-defined either...
>
>    "Typical" also depends on the language. What is typical in one language
> might not be in another. (For example, in Java it's normal and expected for
> the code to be full of 'new' keywords everywhere. If you do that in C++,
> most expert C++ programmers will cringe.)
>

Sure. And on the third hand, what's typical in a language gets optimized in 
that language. It's typical for virtual functions to not go through a 
dispatch table in Java if they don't actually have any other class 
overriding them, while C++ can't generally manage this. So it's "typical" to 
not make things virtual in C++ that are virtual in Java, but Java optimizes 
that bit and C++ doesn't.

For example, it's also "typical" (or at least getting typical) for the Java 
compiler to optimize out heap allocations (i.e., turn "new" into an alloca() 
sort of operation) in ways that C++ would never try.

That's why it's useful to benchmark "typical" ways of doing things. Anything 
small enough to not be different in "typical" methods is probably not 
something that's useful to benchmark, unless you're (say) comparing two tiny 
programs in the *same* language to see which VM or compiler does a better 
optimization job.

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.