POV-Ray : Newsgroups : povray.programming : Improved intersection routine for CSG-Intersection objects : Re: [OT] Re: Improved intersection routine for CSG-Intersection objects Server Time
6 Oct 2024 15:22:17 EDT (-0400)
  Re: [OT] Re: Improved intersection routine for CSG-Intersection objects  
From: Thorsten Froehlich
Date: 16 Dec 2003 16:42:50
Message: <3fdf7c5a$1@news.povray.org>
In article <3fdf63e3@news.povray.org> , Nicolas Calimet <pov### [at] freefr>
wrote:

>>   The sad thing is that sometimes the "C-way" will be slower and less
>> efficient than the "C++-way". For instance, compare C and C++ strings.
>> (Most operations are much faster in C++, not to talk about C++ strings
>> being a lot more secure with regard to memory leaking. C++ strings are
>> also a lot easier to use.)
>
>  But in what language the C++ streams are implemented internally ?
> Isn't it mostly in C and asm ?  The C libraries usually are too.

The C++ streams tend to be slow due to practically all libraries
implementing them in the simplest, not fastest manner.  Practically they
just put a layer on top of C streams, wrap it yet again, then they pull in
more locale and half of the rest of STL and easily you get a huge program if
you just use something as trivial as even a simple cout <sigh>

Guides have been written how to make C++ streams fast, but I don't think any
big STL or compiler vendor has implemented all of them yet.

>  I'm interested in this particular point since my own projects
> rely _a lot_ on labelled data (using my own C string "library").  Could you
> give an example where C++ strings clearly outperform the equivalent C code
> (if anything similar can be done) ?

The STL string, if implemented well, is extremely fast, especially if you
deal with dynamic string length and need to copy strings around.  In fact,
the strings are usually one of the best optimised things in current STL
library implementations...

>>   (It's really sad that C++ streams are still slower than C streams in
>> most compilers. When will they make an implementation which is at least
>> as fast?)
>
>  Ah ! Since I usually write GB of data, it seems that I still have
> a good reason to "kiss" C a bit longer  ;-)

It really depends.  Taker a look at povdocgen (in Perforce).  You will
notice that is reads and writes data very quickly, and it uses only STL
strings.  It really is only so "slow" processing everything because of the
massive applying of regular expressions.  The most important thing is that
STL strings make use of strings almost trivial just like it is in most
higher level languages (i.e. modern Basic variants).

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

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