Tests of malloc and new [] for cygwin and mingw 3.2 and 3.3 and linux
gcc 3.3.
Someone please fill in numbers for 'native' windows compilers, such as
visual C and Intel.
=== Times, running under msys on a Windows 2000 PII-300 system
System real user sys
mingw333 17.936 0.030 0.040
cygwin331 72.394 0.020 0.060
Cmingw333 12.277 0.010 0.060
Ccygwin331 24.355 0.030 0.050
System real user sys
mingw323 18.837 0.020 0.040
mingw32 14.160 0.010 0.060
cygwin32 15.933 0.020 0.050
Cmingw32 12.668 0.030 0.040
Ccygwin32 14.410 0.010 0.080
=== Times, running under bash on a Debian PII-400 system
System real user sys
linux332 4.808 4.800 0.010
Clinux332 3.162 3.160 0.000
=== Versions
mingw32 3.2 (mingw special 20020817-1)
mingw323 3.2.3 (mingw special 20030504-1)
mingw333 3.3.3 (mingw special)
cygwin32 3.2 (20020927 prerelease), linked against stdc++.dll
cygwin331 3.3.1-3 (cygming special)
linux332 3.3.2 20030908 (Debian prerelease)
=== C++ Compiled with g++ -O2. Run under msys.
// Author Paul Thomas
#include <iostream>
using namespace std;
int main()
{
for (int iloop = 0; iloop < 10000000; iloop++)
{
double *myarray;
if ((myarray = new double [1]) == NULL)
cout << "unable to allocate my array at iloop=" << iloop << endl;
delete [] myarray;
}
cout << "done looping" << endl;
return 0;
}
=== C Compiled with gcc -O2. Run under msys.
/* modified from C++ by Paul Kienzle */
#include <stdio.h>
int main()
{
int iloop;
for (iloop = 0; iloop < 10000000; iloop++)
{
double *myarray = (double *)malloc(sizeof(double));
if (myarray== NULL) { printf("alloc failed\n"); exit(1); }
else free (myarray);
}
return 0;
}