This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/14563] new/delete much slower than malloc/free because of sjlj exceptions


------- Additional Comments From ron_hylton at hotmail dot com  2004-11-10 16:20 -------
(In reply to comment #40)
> Ron, can you please attach your testcase that shows the problem to this PR?
> 
> This PR is a regression on cygwin because the speed is back with 3.2.

This is the test case I was using:

#include <iostream>
#include <stdio.h>
#include <time.h>
#include <string>
using namespace std;

int main()
{
	int array_size = 100;
	int loop_count = 3000000;
	try
	{
		long t1 = clock();
		for (int iloop = 0; iloop < loop_count; iloop++)
		{
			int *myarray = new int [array_size];
			delete [] myarray;
		}
		long t2 = clock();
		double delt1 = (double)( t2 - t1 )/ (double)(CLOCKS_PER_SEC);
		cout << "done looping time 1=" << delt1 << endl;
		long t3 = clock();

		for (int jloop = 0; jloop < loop_count; jloop++)
		{
			int *myarray = (int *)malloc(array_size * sizeof(int));
			if (myarray== NULL) { printf("alloc failed\n"); exit(1); }
			else free (myarray);
		}
		long t4 = clock();
		double delt2 = (double)( t4 - t3 )/ (double)(CLOCKS_PER_SEC);
		cout << "done looping time 2=" << delt2 << endl;
	}
	catch (...)
	{
		cout << "exception" << std::endl;
		return 1;
	}

	return 0;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14563


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]