473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

[Comparative performance] Various forms of argument passing


Various forms of argument passing
=================================

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


===================== Forms of argument passing : BEGIN =====================

------ Tested functions ------

void foo_char_ptr (char* ) {} // via char ptr
void foo_char_array (char[] ) {} // via char array

void foo_string_ref (const string& ) {} // via ref to string
void foo_string_value (string ) {} // via string value

void foo_vector_ref (const vector<char>& ) {} // via ref to vector
void foo_vector_value (vector<char> ) {} // via vector value

void foo_list_ref (const list<char>& ) {} // via ref to list
void foo_list_value (list<char> ) {} // via list value

void foo_set_ref (const set<size_t>& ) {} // via ref to set
void foo_set_value (set<size_t> ) {} // via set value

void foo_map_ref (const map<size_t, int>& ) {} // via ref to map
void foo_map_value (map<size_t, int> ) {} // via map value
------ Data (fragments) ------

const size_t data_size = <data size>;

string str; // str.size() == data_size
vector<char> vct; // vct.size() == data_size
list<char> lst; // lst.size() == data_size
set<size_t> st; // st.size() == data_size
map<size_t,int> mp; // mp.size() == data_size
char* pcstr; // strlen (pcstr) == data_size
char acstr [data_size + 1]; // strlen (acstr) == data_size

Note. acstr is used only with GNU compiler
------ Calling tested functions ------

foo_char_ptr (pcstr); // char ptr via char ptr
foo_char_array (pcstr); // char ptr via char array
foo_char_ptr (acstr); // char array via char ptr
foo_char_array (acstr); // char array via char array

foo_string_ref (str); // string via ref to string
foo_string_value (str); // string via string value
foo_string_ref (pcstr); // char ptr via ref to string
foo_string_value (pcstr); // char ptr via string value
foo_string_ref (acstr); // char array via ref to string
foo_string_value (acstr); // char array via string value

foo_vector_ref (vct); // vector<char> via ref to vector
foo_vector_value (vct); // vector<char> via vector value
foo_list_ref (lst); // list<char> via ref to list
foo_list_value (lst); // list<char> via list value
foo_set_ref (st); // set<size_t> via ref to set
foo_set_value (st); // set<size_t> via set value
foo_map_ref (mp); // map<size_t, int> via ref to map
foo_map_value (mp); // map<size_t, int> via map value
===================== Forms of argument passing : END =======================

================ Performance tests : BEGIN ================

#================================================= =========
# Comparison : various forms of argument passing
#----------------------------------------------------------
# Resource Name : user time used (via rusage)
# Resource Cost Unit : milliseconds (unsigned long long)
# per 10000000 calls (repetitions)
# Resource State Unit : timeval
#================================================= =========

Summary test results
====================
----------------------------------------------------------------------------
| | | User time used for |
| N | Form of argument passing | data size |
| | |-----------------------------|
| | | 10 | 100 | 1000 |
|--------------------------------------------------------------------------|
| 1 | char ptr via char ptr | 80 | 80 | 70 |
| 2 | char ptr via char array | 70 | 70 | 70 |
| 3 | char array via char ptr | 70 | 70 | 80 |
| 4 | char array via char array | 80 | 69 | 70 |
| | | | | |
| 5 | string via ref to string | 70 | 70 | 80 |
| 6 | string via string value | 4000 | 4000 | 4200 |
| 7 | char ptr via ref to string | 8500 | 15000 | 93300 |
| 8 | char ptr via string value | 9000 | 15000 | 90200 |
| 9 | char array via ref to string | 8800 | 15100 | 89900 |
| 10 | char array via string value | 8900 | 15000 | 90100 |
| | | | | |
| 11 | vector<char> via ref to vector | 70 | 70 | 70 |
| 12 | vector<char> via vector value | 10900 | 12000 | 38500 |
| 13 | list<char> via ref to list | 80 | 80 | 70 |
| 14 | list<char> via list value | 41000 | 361000 | 3563000 |
| 15 | set<size_t> via ref to set | 70 | 70 | 79 |
| 16 | set<size_t> via set value | 43000 | 400000 | 4199000 |
| 17 | map<size_t, int> via ref to map | 71 | 81 | 71 |
| 18 | map<size_t, int> via map value | 42000 | 373000 | 4207000 |
----------------------------------------------------------------------------
Comment-question. 'string via string value' doesn't depend on data size (?)

================ Performance tests : END ==================
==============================================
Alex Vinokur
mailto:al****@connect.to
http://mathforum.org/library/view/10978.html
==============================================

Jul 19 '05 #1
8 3931
"Alex Vinokur" <al****@bigfoot.com> writes:
Comment-question. 'string via string value' doesn't depend on
data size (?)


Some implementations of std::string use copy-on-write semantics
internally.
Jul 19 '05 #2
On Mon, 1 Sep 2003 13:57:29 +0300, "Alex Vinokur" <al****@bigfoot.com>
wrote in comp.lang.c++:

Various forms of argument passing
=================================

C/C++ Performance Tests
=======================
Using C/C++ Program Perfometer
http://sourceforge.net/projects/cpp-perfometer
http://alexvn.freeservers.com/s1/perfometer.html


[snip]

This is probably very much on-topic in comp.software.measurement, but
it is very much OFF-TOPIC in comp.lang.c. Please STOP cross-posting
this stuff to comp.lang.c.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Jul 19 '05 #3

"Florian Weimer" <fw@deneb.enyo.de> wrote in message news:87************@deneb.enyo.de...
"Alex Vinokur" <al****@bigfoot.com> writes:
Comment-question. 'string via string value' doesn't depend on
data size (?)


Some implementations of std::string use copy-on-write semantics
internally.


Does it have to do with copy-initialization?

=====================================
Alex Vinokur
mailto:al****@connect.to
http://mathforum.org/library/view/10978.html
=====================================
Jul 19 '05 #4

"Jack Klein" <ja*******@spamcop.net> wrote in message news:o1********************************@4ax.com...
On Mon, 1 Sep 2003 13:57:29 +0300, "Alex Vinokur" <al****@bigfoot.com>
wrote in comp.lang.c++:

Various forms of argument passing
=================================

C/C++ Performance Tests
=======================
Using C/C++ Program Perfometer
http://sourceforge.net/projects/cpp-perfometer
http://alexvn.freeservers.com/s1/perfometer.html


[snip]

This is probably very much on-topic in comp.software.measurement, but
it is very much OFF-TOPIC in comp.lang.c. Please STOP cross-posting
this stuff to comp.lang.c.

[snip]

The message named "[Comparative performance] Various forms of argument passing" has never been posted to news:comp.lang.c.

=====================================
Alex Vinokur
mailto:al****@connect.to
http://mathforum.org/library/view/10978.html
=====================================
Jul 19 '05 #5
Mon

Alex Vinokur <al****@bigfoot.com> wrote in message
news:bi************@ID-79865.news.uni-berlin.de...

Various forms of argument passing
=================================

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


===================== Forms of argument passing : BEGIN =====================
------ Tested functions ------

void foo_char_ptr (char* ) {} // via char ptr
void foo_char_array (char[] ) {} // via char array

void foo_string_ref (const string& ) {} // via ref to string void foo_string_value (string ) {} // via string value

void foo_vector_ref (const vector<char>& ) {} // via ref to vector void foo_vector_value (vector<char> ) {} // via vector value

void foo_list_ref (const list<char>& ) {} // via ref to list
void foo_list_value (list<char> ) {} // via list value

void foo_set_ref (const set<size_t>& ) {} // via ref to set
void foo_set_value (set<size_t> ) {} // via set value

void foo_map_ref (const map<size_t, int>& ) {} // via ref to map
void foo_map_value (map<size_t, int> ) {} // via map value
------ Data (fragments) ------

const size_t data_size = <data size>;

string str; // str.size() == data_size
vector<char> vct; // vct.size() == data_size
list<char> lst; // lst.size() == data_size
set<size_t> st; // st.size() == data_size
map<size_t,int> mp; // mp.size() == data_size
char* pcstr; // strlen (pcstr) == data_size
char acstr [data_size + 1]; // strlen (acstr) == data_size

Note. acstr is used only with GNU compiler
------ Calling tested functions ------

foo_char_ptr (pcstr); // char ptr via char ptr
foo_char_array (pcstr); // char ptr via char array
foo_char_ptr (acstr); // char array via char ptr
foo_char_array (acstr); // char array via char array

foo_string_ref (str); // string via ref to string
foo_string_value (str); // string via string value
foo_string_ref (pcstr); // char ptr via ref to string
foo_string_value (pcstr); // char ptr via string value
foo_string_ref (acstr); // char array via ref to string
foo_string_value (acstr); // char array via string value

foo_vector_ref (vct); // vector<char> via ref to vector
foo_vector_value (vct); // vector<char> via vector value
foo_list_ref (lst); // list<char> via ref to list
foo_list_value (lst); // list<char> via list value
foo_set_ref (st); // set<size_t> via ref to set
foo_set_value (st); // set<size_t> via set value
foo_map_ref (mp); // map<size_t, int> via ref to map
foo_map_value (mp); // map<size_t, int> via map value
===================== Forms of argument passing : END =======================
================ Performance tests : BEGIN ================

#================================================= =========
# Comparison : various forms of argument passing
#----------------------------------------------------------
# Resource Name : user time used (via rusage)
# Resource Cost Unit : milliseconds (unsigned long long)
# per 10000000 calls (repetitions)
# Resource State Unit : timeval
#================================================= =========

Summary test results
====================
----------------------------------------------------------------------- ----- | | | User time used for | | N | Form of argument passing | data size | | | |-----------------------------| | | | 10 | 100 | 1000 | |--------------------------------------------------------------------------| | 1 | char ptr via char ptr | 80 | 80 | 70 | | 2 | char ptr via char array | 70 | 70 | 70 | | 3 | char array via char ptr | 70 | 70 | 80 | | 4 | char array via char array | 80 | 69 | 70 | | | | | | | | 5 | string via ref to string | 70 | 70 | 80 | | 6 | string via string value | 4000 | 4000 | 4200 | | 7 | char ptr via ref to string | 8500 | 15000 | 93300 | | 8 | char ptr via string value | 9000 | 15000 | 90200 | | 9 | char array via ref to string | 8800 | 15100 | 89900 | | 10 | char array via string value | 8900 | 15000 | 90100 | | | | | | | | 11 | vector<char> via ref to vector | 70 | 70 | 70 | | 12 | vector<char> via vector value | 10900 | 12000 | 38500 | | 13 | list<char> via ref to list | 80 | 80 | 70 | | 14 | list<char> via list value | 41000 | 361000 | 3563000 | | 15 | set<size_t> via ref to set | 70 | 70 | 79 | | 16 | set<size_t> via set value | 43000 | 400000 | 4199000 | | 17 | map<size_t, int> via ref to map | 71 | 81 | 71 | | 18 | map<size_t, int> via map value | 42000 | 373000 | 4207000 | ----------------------------------------------------------------------- ----- Comment-question. 'string via string value' doesn't depend on data size (?)
================ Performance tests : END ==================
==============================================
Alex Vinokur
mailto:al****@connect.to
http://mathforum.org/library/view/10978.html
==============================================


Jul 19 '05 #6
Mon
Can the posters to this thread please confine themselves to their own
newsgroup & stop cross-posting
Alex Vinokur <al****@bigfoot.com> wrote in message
news:bi************@ID-79865.news.uni-berlin.de...

Various forms of argument passing
=================================

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


===================== Forms of argument passing : BEGIN =====================
------ Tested functions ------

void foo_char_ptr (char* ) {} // via char ptr
void foo_char_array (char[] ) {} // via char array

void foo_string_ref (const string& ) {} // via ref to string void foo_string_value (string ) {} // via string value

void foo_vector_ref (const vector<char>& ) {} // via ref to vector void foo_vector_value (vector<char> ) {} // via vector value

void foo_list_ref (const list<char>& ) {} // via ref to list
void foo_list_value (list<char> ) {} // via list value

void foo_set_ref (const set<size_t>& ) {} // via ref to set
void foo_set_value (set<size_t> ) {} // via set value

void foo_map_ref (const map<size_t, int>& ) {} // via ref to map
void foo_map_value (map<size_t, int> ) {} // via map value
------ Data (fragments) ------

const size_t data_size = <data size>;

string str; // str.size() == data_size
vector<char> vct; // vct.size() == data_size
list<char> lst; // lst.size() == data_size
set<size_t> st; // st.size() == data_size
map<size_t,int> mp; // mp.size() == data_size
char* pcstr; // strlen (pcstr) == data_size
char acstr [data_size + 1]; // strlen (acstr) == data_size

Note. acstr is used only with GNU compiler
------ Calling tested functions ------

foo_char_ptr (pcstr); // char ptr via char ptr
foo_char_array (pcstr); // char ptr via char array
foo_char_ptr (acstr); // char array via char ptr
foo_char_array (acstr); // char array via char array

foo_string_ref (str); // string via ref to string
foo_string_value (str); // string via string value
foo_string_ref (pcstr); // char ptr via ref to string
foo_string_value (pcstr); // char ptr via string value
foo_string_ref (acstr); // char array via ref to string
foo_string_value (acstr); // char array via string value

foo_vector_ref (vct); // vector<char> via ref to vector
foo_vector_value (vct); // vector<char> via vector value
foo_list_ref (lst); // list<char> via ref to list
foo_list_value (lst); // list<char> via list value
foo_set_ref (st); // set<size_t> via ref to set
foo_set_value (st); // set<size_t> via set value
foo_map_ref (mp); // map<size_t, int> via ref to map
foo_map_value (mp); // map<size_t, int> via map value
===================== Forms of argument passing : END =======================
================ Performance tests : BEGIN ================

#================================================= =========
# Comparison : various forms of argument passing
#----------------------------------------------------------
# Resource Name : user time used (via rusage)
# Resource Cost Unit : milliseconds (unsigned long long)
# per 10000000 calls (repetitions)
# Resource State Unit : timeval
#================================================= =========

Summary test results
====================
----------------------------------------------------------------------- ----- | | | User time used for | | N | Form of argument passing | data size | | | |-----------------------------| | | | 10 | 100 | 1000 | |--------------------------------------------------------------------------| | 1 | char ptr via char ptr | 80 | 80 | 70 | | 2 | char ptr via char array | 70 | 70 | 70 | | 3 | char array via char ptr | 70 | 70 | 80 | | 4 | char array via char array | 80 | 69 | 70 | | | | | | | | 5 | string via ref to string | 70 | 70 | 80 | | 6 | string via string value | 4000 | 4000 | 4200 | | 7 | char ptr via ref to string | 8500 | 15000 | 93300 | | 8 | char ptr via string value | 9000 | 15000 | 90200 | | 9 | char array via ref to string | 8800 | 15100 | 89900 | | 10 | char array via string value | 8900 | 15000 | 90100 | | | | | | | | 11 | vector<char> via ref to vector | 70 | 70 | 70 | | 12 | vector<char> via vector value | 10900 | 12000 | 38500 | | 13 | list<char> via ref to list | 80 | 80 | 70 | | 14 | list<char> via list value | 41000 | 361000 | 3563000 | | 15 | set<size_t> via ref to set | 70 | 70 | 79 | | 16 | set<size_t> via set value | 43000 | 400000 | 4199000 | | 17 | map<size_t, int> via ref to map | 71 | 81 | 71 | | 18 | map<size_t, int> via map value | 42000 | 373000 | 4207000 | ----------------------------------------------------------------------- ----- Comment-question. 'string via string value' doesn't depend on data size (?)
================ Performance tests : END ==================
==============================================
Alex Vinokur
mailto:al****@connect.to
http://mathforum.org/library/view/10978.html
==============================================


Jul 19 '05 #7
"Alex Vinokur" <al****@bigfoot.com> writes:
"Florian Weimer" <fw@deneb.enyo.de> wrote in message news:87************@deneb.enyo.de...
"Alex Vinokur" <al****@bigfoot.com> writes:
> Comment-question. 'string via string value' doesn't depend on
> data size (?)


Some implementations of std::string use copy-on-write semantics
internally.


Does it have to do with copy-initialization?


Yes.
Jul 19 '05 #8
"Alex Vinokur" <al****@bigfoot.com> writes:
Comment-question. 'string via string value' doesn't depend on
data size (?)


Some implementations of std::string use copy-on-write semantics
internally.


Does it have to do with copy-initialization?


I'd think so. You just have to copy a few pointers and increment a
reference count in the copy constructor.
Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alex Vinokur | last post by:
Copying files : input to output =============================== C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer...
0
by: Alex Vinokur | last post by:
=================================== ------------- Sorting ------------- Comparative performance measurement =================================== Testsuite : Comparing Function Objects to...
6
by: FireHawkBr® | last post by:
Hi, My company uses Informix as corporative database. As experienced DBA of the company, I have that to make a study comparing Oracle, Informix and DB2 databases and suggesting new alternatives....
6
by: Alex Vinokur | last post by:
Here are results of comparative performance tests carried out using the same compiler (gcc 3.2) in different environments (CYGWIN, MINGW, DJGPP) on Windows 2000 Professional. The following...
6
by: toton | last post by:
Hi, Anyone have a link to comparative study of different C++ compilers and how much they conform to C++ language standard? Most of the big platforms I know have GCC which well supports C++...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
1
by: ianwr | last post by:
Hi, I wondered in anyone can help with the following problem that i'm experiencing, i'll try to provide as much info as possible and any suggestions would be appreciated. I have just started...
2
by: josrom | last post by:
Someone knows where to obtain a comparative picture of Performance Between Pro*C Code and PL/SQL Code??? Tested Items ------------------------ Owner SQL Portability Structure...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.