Mail Archives: cygwin/2004/07/18/08:00:43
Hi,
How to explain so considerable difference in performance: g++ Cygwin vs. other compilers in tests below?
Simple C/C++ Perfometer : Copying char[] to vector (Version CS-1.0)
* func_memcpy
* func_copy
* func_copy_with_reserve
* func_transform
* func_ctor
* The whole program at http://thread.gmane.org/gmane.comp.lang.c++.perfometer/58
contains the following files :
- copystr.h // Header file : http://article.gmane.org/gmane.comp.lang.c++.perfometer/58/
- info.cpp // Information about compiler : http://article.gmane.org/gmane.comp.lang.c++.perfometer/59/
- cps_test.cpp // Function tested : http://article.gmane.org/gmane.comp.lang.c++.perfometer/60/
- cps_main.cpp // Main program : http://article.gmane.org/gmane.comp.lang.c++.perfometer/61/
Payload code : cps_test.cpp.
Housekeeping code : copystr.h, info.cpp, cps_main.cpp.
###### C++ Code Tested : BEGIN ######
// Code from http://article.gmane.org/gmane.comp.lang.c++.perfometer/60
#define STR_LEN 100
char cstr[STR_LEN];
struct char_identity
{
char operator()(char ch) const { return ch; }
};
// ====== Function tested using Simple C++ Perfometer ======
void func_memcpy()
{
vector<char> vect (STR_LEN);
memcpy(&vect[0], cstr, STR_LEN);
}
void func_copy()
{
vector<char> vect;
copy(cstr, cstr + STR_LEN, back_inserter(vect));
}
void func_copy_with_reserve()
{
vector<char> vect;
vect.reserve(STR_LEN);
copy(cstr, cstr + STR_LEN, back_inserter(vect));
}
void func_transform()
{
vector<char> vect (STR_LEN);
transform(cstr, cstr + STR_LEN, vect.begin(), char_identity());
}
void func_ctor()
{
vector<char> vect (cstr, cstr + STR_LEN);
}
// =========================================================
###### C++ Code Tested : END ########
###### Run Log (Fragments) : BEGIN ########
From http://article.gmane.org/gmane.comp.lang.c++.perfometer/62/
========================================
Simple C/C++ Perfometer : Copying String
Version CS-1.0
========================================
C/C++ Performance Tests
=======================
Using Simple C/C++ Perfometer (Copying char[] to vector), Version CS-1.0
http://thread.gmane.org/gmane.comp.lang.c++.perfometer/58/ (The whole program)
http://article.gmane.org/gmane.comp.lang.c++.perfometer/60/ (Functions tested only)
Environment
-----------
Windows 2000 Professional
Intel(R) Celeron(R) CPU 1.70 GHz
####################################
### Compilation with no optimization
####################################
### char[] size : 100
### Number of repetitions : 100000
----------------------
GNU gcc 3.3.1 (CYGWIN)
----------------------
### CLOCKS_PER_SEC : 1000
func_memcpy : 2937 units (2.937 secs)
func_copy : 14487 units (14.487 secs)
func_copy_with_reserve : 4098 units (4.098 secs)
func_transform : 3428 units (3.428 secs)
func_ctor : 2944 units (2.944 secs)
---------------------
GNU gcc 3.3.1 (MINGW)
---------------------
### CLOCKS_PER_SEC : 1000
func_memcpy : 74 units (0.074 secs)
func_copy : 1117 units (1.117 secs)
func_copy_with_reserve : 584 units (0.584 secs)
func_transform : 303 units (0.303 secs)
func_ctor : 57 units (0.057 secs)
-------------------------
GNU gcc 3.3.4 (DGGPP 2.3)
-------------------------
### CLOCKS_PER_SEC : 91
func_memcpy : 11 units (0.121 secs)
func_copy : 243 units (2.670 secs)
func_copy_with_reserve : 121 units (1.330 secs)
func_transform : 65 units (0.714 secs)
func_ctor : 10 units (0.110 secs)
-------------------------------
Microsoft C++ 13.00 (Unmanaged)
-------------------------------
### CLOCKS_PER_SEC : 1000
func_memcpy : 1465 units (1.465 secs)
func_copy : 13202 units (13.202 secs)
func_copy_with_reserve : 4609 units (4.609 secs)
func_transform : 1963 units (1.963 secs)
func_ctor : 1378 units (1.378 secs)
-------------------------
Digital Mars C/C++ 8.40.2
-------------------------
### CLOCKS_PER_SEC : 1000
func_memcpy : 63 units (0.063 secs)
func_copy : 574 units (0.574 secs)
func_copy_with_reserve : 220 units (0.220 secs)
func_transform : 130 units (0.130 secs)
func_ctor : 60 units (0.060 secs)
###### Run Log (Fragments) : END ##########
List of the functions sorted according to performance:
* func_ctor (the fastest)
* func_memcpy
* func_transform
* func_copy_with_reserve
* func_copy
--
Alex Vinokur
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -