Пример #1
0
int main(void)
{
	int i, count;
	Timer t;

	count = 1000000;

	t.Start();
	for(i = 0; i < count; i++){
		twine tmp;
		tmp.format("This is (%d) a message (%s) with several (%f) "
			"replacement (%d) parameters (%s)",
			i, "hithere everyone", 3.14159f, i*2,
			"interesting isn't it? ;-)");
	}
	t.Finish();

	printf("Time for %d twine::format calls is (%f)\n", 
		count, t.Duration());

	return 0;
}
Пример #2
0
void *run_lots(void* v)
{
	EnEx ee("run_lots()", true);
	int i, j;
	Timer tt;
	
	tt.Start();
	for(j = 0; j < 20; j++){
		EnEx eeo("run_lots() - main loop");
		vector < data_class * > *myvect;
		myvect = new vector < data_class * >;
		string accumulator;
		for(i = 0; i < 60000; i++){
			EnEx eei("run_lots() - inner loop");
			data_class *dat = new data_class();
			dat->field1 = "field 1 value";
			dat->field2 = "field 2 value";
			dat->field3 = dat->field1;
			dat->field3 += dat->field2;
			dat->field4 = "57.89f";
			dat->field5 = "A string ";
			dat->field5 += "35 ";
			dat->field5 += "38.99";
			dat->i1 = 18;
			dat->i2 = 19;
			dat->i3 = dat->i1 * dat->i2;
			dat->field6 = "ANumber";
			dat->field7 = "AnotherNumber";
			dat->field8 = "AThirdNumber";
			dat->field9 = dat->field2.substr(3, 5);
			if(dat->field1 > dat->field2)
				dat->fielda = "true";
			else
				dat->fielda = "false";
			myvect->push_back(dat);	
			accumulator += dat->field8;
		}
		for(i = 0; i < (int)myvect->size(); i++){
			delete (*myvect)[i];
		}
		delete myvect;
	}
	tt.Finish();
	printf("Duration for the regular stuff is (%f)\n", tt.Duration());

	tt.Start();

	for(j = 0; j < 20; j++){
		for(i = 0; i < 60000; i++){
			string ret_tmp;

			ret_tmp = func1("interesting");

		}
	}

	tt.Finish();
	printf("Duration for the func stuff is (%f)\n", tt.Duration());

	return (void*)NULL;
}