"Ivan Vecerina" <iv**@myrealbox.com> wrote in message news:3f********@news.swissonline.ch...
"Alex Vinokur" <al****@bigfoot.com> wrote in message
news:bi************@ID-79865.news.uni-berlin.de...
| Method-6 : Method sbumpc() and operator <<
| ch = in_fs.rdbuf()->sbumpc();
| out_fs << ch;
| while (ch != EOF)
| {
| out_fs << in_fs.rdbuf();
| ch = in_fs.rdbuf()->sbumpc();
| }
Isn't this equivalent to just writing:
out_fs << in_fs.rdbuf();
My library doc says that this overload of << copies characters
from the source buffer until EOF is reached.
[snip]
Thanks.
Here are summary results of changed tests.
Copying files : input to output
===============================
C/C++ Performance Tests
=======================
Using C/C++ Program Perfometer
http://sourceforge.net/projects/cpp-perfometer http://alexvn.freeservers.com/s1/perfometer.html
Environment
-----------
Windows 2000 Professional
CYGWIN_NT-5.0 1.3.22(0.78/3/2)
Intel(R) Celeron(R) CPU 1.70 GHz
GNU gcc/g++ version 3.2 20020927 (prerelease)
Compilation : No optimization
#################################################
Stream I/O performance tests below are based
on the article "Stream I/O"
presented at
http://www.glenmccl.com/strm_cmp.htm
by Glen McCluskey & Associates LLC
#################################################
===================== Methods of copying : BEGIN =====================
ifstream in_fs;
ofstream out_fs;
FILE* in_fp;
FILE* out_fp;
char ch;
int ich;
Method C-1 : Functions getc() and putc()
-----------------------------------------------------
while ((ich = getc(in_fp)) != EOF) putc(ich, out_fp);
-----------------------------------------------------
Method C-2 : Functions fgetc() and fputc()
-------------------------------------------------------
while ((ich = fgetc(in_fp)) != EOF) fputc(ich, out_fp);
-------------------------------------------------------
Method CPP-1 : Operators >> and <<
---------------------------------
in_fs.unsetf(ios::skipws);
while (in_fs >> ch) out_fs << ch;
---------------------------------
Method CPP-2 : Methods get() and put()
-------------------------------------
while (in_fs.get(ch)) out_fs.put(ch);
-------------------------------------
Method CPP-3 : Methods sbumpc() and sputc()
------------------------------------------------------------------------
while ((ch = in_fs.rdbuf()->sbumpc()) != EOF) out_fs.rdbuf()->sputc(ch);
------------------------------------------------------------------------
Method CPP-4 : Method sbumpc() and operator <<
-------------------------------
ch = in_fs.rdbuf()->sbumpc();
out_fs << ch;
while (ch != EOF)
{
out_fs << in_fs.rdbuf();
ch = in_fs.rdbuf()->sbumpc();
}
-------------------------------
Method CPP-5 : Method rdbuf() and operator <<
------------------------
out_fs << in_fs.rdbuf();
------------------------
===================== Methods of copying : END =======================
================ Performance tests : BEGIN ================
#================================================= =========
# Comparison : copying files : input to output
#----------------------------------------------------------
# Resource Name : user time used (via rusage)
# Resource Cost Unit : milliseconds (unsigned long long)
# Resource State Unit : timeval
#================================================= =========
Summary test results (Run-3)
============================
--------------------------------------------------------------------
| | | User time used for |
| No. | Method | file size |
| | |-----------------------|
| | | 100 | 1000 | 10000 |
|------------------------------------------------------------------|
| C-1 | Functions getc() and putc() | 60 | 177 | 1625 |
| C-2 | Functions fgetc() and fputc() | 53 | 186 | 1749 |
| | | | | |
| CPP-1 | Operators >> and << | 226 | 1662 | 15984 |
| CPP-2 | Methods get() and put() | 136 | 796 | 7562 |
| CPP-3 | Methods sbumpc() and sputc() | 88 | 448 | 3930 |
| CPP-4 | Method sbumpc() and operator << | 65 | 155 | 1483 |
| CPP-5 | Method rdbuf() and operator << | 78 | 173 | 1440 |
--------------------------------------------------------------------
Raw Log :
http://groups.google.com/groups?selm....uni-berlin.de
Summary test results (Run-4)
============================
--------------------------------------------------------------------
| | | User time used for |
| No. | Method | file size |
| | |-----------------------|
| | | 100 | 1000 | 10000 |
|------------------------------------------------------------------|
| C-1 | Functions getc() and putc() | 40 | 103 | 1342 |
| C-2 | Functions fgetc() and fputc() | 64 | 113 | 1265 |
| | | | | |
| CPP-1 | Operators >> and << | 179 | 1225 | 14768 |
| CPP-2 | Methods get() and put() | 96 | 614 | 7324 |
| CPP-3 | Methods sbumpc() and sputc() | 76 | 350 | 3741 |
| CPP-4 | Method sbumpc() and operator << | 57 | 130 | 1469 |
| CPP-5 | Method rdbuf() and operator << | 70 | 153 | 1432 |
--------------------------------------------------------------------
Raw Log :
http://groups.google.com/groups?selm....uni-berlin.de
================ Performance tests : END ==================
==============================================
Alex Vinokur
mailto:al****@connect.to
http://mathforum.org/library/view/10978.html
==============================================