Exemple #1
0
int main(int argc, const char * argv[]) {
	TFPerformanceTimer performaceTimer;
	{
		performaceTimer.start();
		for (int i = 0; i < OBJECT_COUNT; i++) {
			new TestObject();
		}
		std::cout << "Took " << (double)performaceTimer.stop()/1000000 << "ms to new " << OBJECT_COUNT << " objects" << std::endl;
	}
	
	{
		TFObjectPool<TestObject> objectPool(OBJECT_COUNT);
		performaceTimer.start();
		for (int i = 0; i < OBJECT_COUNT; i++) {
			objectPool.allocateObject();
		}
		std::cout << "Took " << (double)performaceTimer.stop()/1000000 << "ms to allocate " << OBJECT_COUNT << " objects from pool" << std::endl;
	}

	{
		TFObjectPool<TestObject> objectPool(OBJECT_COUNT);
		std::vector<TestObject *> m_objects(OBJECT_COUNT);
		for (int i = 0; i < OBJECT_COUNT; i++) {
			m_objects.push_back(objectPool.allocateObject());
		}
		
		std::vector<TestObject *>::const_iterator it = m_objects.begin();
		performaceTimer.start();
		for (;it != m_objects.end(); it++) {
			objectPool.release(*it);
		}
		std::cout << "Took " << (double)performaceTimer.stop()/1000000 << "ms to release " << OBJECT_COUNT << " objects from pool" << std::endl;
	}

	{
		TFObjectPool<TestObject> objectPool(1);
		performaceTimer.start();
		for (int i = 0; i < OBJECT_COUNT; i++) {
			objectPool.allocateObject();
		}
		std::cout << "Took " << (double)performaceTimer.stop()/1000000 << "ms to allocate " << OBJECT_COUNT << " objects from pool" << std::endl;
	}


	performaceTimer.start();
	TFRingBuffer<TestObject> ringBuffer(20);

	
	std::cout << "Took " << (double)performaceTimer.stop()/1000000 << "ms to allocate " << OBJECT_COUNT << " objects from pool" << std::endl;

    return 0;
}
Exemple #2
0
void Integrator::amend() {
    try {
        mainWindow = objectPool()->find<QMainWindow*>("mainWindow");
    }
    catch (Exception &) {
        mainWindow = 0;
    }
}
Exemple #3
0
OutputMaker* OutputMaker::me() {
    if (!_me)
        _me = objectPool()->find<OutputMaker*>(id());
    return _me;
}
IntegratorMaker* IntegratorMaker::me() {
    if (!_me)
        _me = objectPool()->find<IntegratorMaker*>(id());
    return _me;
}
Exemple #5
0
FileLocations* FileLocations::me() {
    if (!_me)
        _me = objectPool()->find<FileLocations*>(id());
    return _me;
}