Boost logo

Boost :

From: Fedder Skovgaard (fsk_at_[hidden])
Date: 2002-03-19 07:56:44


Hi,

I think it's a viable route to take. Nicolai Josuttis writes: "This is
probably the fastest way to copy files by using C++ I/O streams."
See"The C++ standard Library" (ISBN 0201379260) Chapter 13.14.3.

You should, obviously be able to get better performance by using platform
specific calls and technologies (such as Asynchroneous IO and Memory mapped
files on Win32).

But the point lies (in my perspective) in the subphrase "by using C++ I/O
streams". Most operating systems also sports memory management routines
that out-perform new / delete for specific purposes, but that doesn't mean
that new / delete is a bad thing.

Just my two cents.

Fedder

                                                                                                                                              
                                                                                                                                              
                        "Alisdair Meredith" To: <boost_at_[hidden]>
                        <alisdair.meredith_at_uk.r cc:
                        enaultf1.com> Subject: Re: [boost] Remarkably efficient file copy
                        Sent by:
                        boost-admin_at_lists.boost
                        .org
                                                                                                                                              
                                                                                                                                              
                        19-03-2002 12:04
                        Please respond to boost
                                                                                                                                              
                                                                                                                                              
                                                                                                                                              

However, it surely performs well as a lowest-common-denominator approach
for a cross-platform library.

Hopefully we can support more optimised solutions for specific platforms,
but something similar should be widely supportable as a fall-back
implementation. Here, it's very simplicity is in its favour!

AlisdairM

>>> gila_at_[hidden] 19 March 2002 06:24:36 >>>
In my tests, I've found a combination of stat, mmap (there's a similar
win32 api), and memcpy to be the fastest implementation available. I
don't have any benchmarks available but it also stands to reason that
handing the file copy routine over to the kernal will yield the best
possible results for a general purpose file copy.

Given that your astoundingly simple implementation is so, well,
simple, it hardly seems to warrent inclusion as a file copy routine
and should just be one of the many tricks in your bag.

On Tue, Mar 19, 2002 at 04:37:33PM +1100, Dylan Nicholson wrote:
> If we definitely decide to put in a "copy_file" routine into
boost::filesystem,
> then believe it or not, the following single line of code is remarkably
> efficient (at least under HP aCC 3.33, which is what I tested it with):
>
> bool copy(const char* src, const char* dest)
> {
> return std::ofstream(dest) << std::ifstream(src).rdbuf();
> }
_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost

----------------------------------------------------------------------

For further information on Renault F1 visit our web site at
www.renaultf1.com. This email and any files transmitted with it are
confidential and intended solely for the use of the individual or entity to
whom they are addressed. If you have received this email in error please
destroy and notify Renault F1 on +44 1608678000."

----------------------------------------------------------------------
_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk