|
PLearn 0.1
|

Go to the source code of this file.
Classes | |
| struct | MyStruct |
Functions | |
| template<bool fast_dealloc> | |
| void | alloc_from_pool () |
| void | alloc_from_stdalloc () |
| int | main () |
Variables | |
| const int | N = 10000000 |
| const int | POOL_SIZE = 10000 |
| const float | GROWTH = 2.0 |
| void alloc_from_pool | ( | ) |
Definition at line 18 of file test_pool.cc.
References PLearn::PObjectPool< T >::allocate(), PLearn::PObjectPool< T >::deallocate(), PLearn::PMemPool::empty(), PLearn::endl(), GROWTH, i, N, and POOL_SIZE.
{
vector<MyStruct*> all_allocated;
all_allocated.reserve(N);
PObjectPool<MyStruct> pool(POOL_SIZE, GROWTH, fast_dealloc);
cout << "Is pool empty? " << pool.empty() << endl;
for (int i=0; i<N; ++i) {
MyStruct* s = pool.allocate();
// cout << "Allocating at " << setbase(16) << (void*)s << endl;
all_allocated.push_back(s);
}
cout << "Is pool empty? " << pool.empty() << endl;
for (int i=N/2; i<N; ++i) {
MyStruct* s = all_allocated[i];
// cout << "Deallocating at " << setbase(16) << (void*)s << endl;
pool.deallocate(s);
}
cout << "Is pool empty? " << pool.empty() << endl;
for (int i=0; i<N/2; ++i) {
MyStruct* s = all_allocated[i];
// cout << "Deallocating at " << setbase(16) << (void*)s << endl;
pool.deallocate(s);
}
cout << "Is pool empty? " << pool.empty() << endl;
}

| void alloc_from_stdalloc | ( | ) |
| int main | ( | ) |
Definition at line 63 of file test_pool.cc.
References alloc_from_stdalloc().
{
alloc_from_pool<false>();
alloc_from_pool<true>();
alloc_from_stdalloc();
};

| const float GROWTH = 2.0 |
Definition at line 15 of file test_pool.cc.
Referenced by alloc_from_pool().
Definition at line 13 of file test_pool.cc.
Referenced by alloc_from_pool(), alloc_from_stdalloc(), PLearn::TinyVector< T, N, TTrait >::assign(), PLearn::TinyVector< int, 7 >::assign(), PLearn::autocorrelation_function(), PLearn::bootstrap_rows(), PLearn::SummationKernel::build_(), PLearn::EntropyContrastLearner::build_(), PLearn::BestAveragingPLearner::build_(), PLearn::PLearner::computeOutputCovMat(), PLearn::GaussianProcessRegressor::computeOutputCovMat(), PLearn::LinearRegressor::computeResidualsVariance(), PLearn::DirichletEstimatorMMoments(), PLearn::eigen_SymmMat(), PLearn::BinaryKernelDiscrimination::evaluate(), PLearn::externalProductDivUpdate(), PLearn::externalProductMultUpdate(), PLearn::VBoundDBN2::fprop(), PLearn::KLp0p1RBMModule::fprop(), PLearn::PDistribution::generateN(), PLearn::TopNI< T >::init(), PLearn::BottomNI< T >::init(), PLearn::InversePowerIteration(), PLearn::KS_test(), PLearn::lapackCholeskyDecompositionInPlace(), PLearn::lapackCholeskySolveInPlace(), PLearn::lapackEIGEN(), PLearn::lapackGeneralizedEIGEN(), PLearn::lapackSolveLinearSystem(), PLearn::lapackSVD(), PLearn::matInvert(), PLearn::TinyVector< int, 7 >::max_size(), PLearn::multivariate_normal(), PLearn::n_choose(), PLearn::new_read_compressed(), PLearn::one_against_all_hinge_loss(), PLearn::one_against_all_hinge_loss_bprop(), PLearn::RemoveObservationTest::perform(), PLearn::PowerIteration(), PLearn::TinyVector< T, N, TTrait >::push_back(), PLearn::qld_interface(), PLearn::TopNI< T >::reset(), PLearn::BottomNI< T >::reset(), PLearn::TinyVector< T, N, TTrait >::resize(), PLearn::VMatLanguage::run(), PLearn::MemoryCachedKernel::setDataForKernelMatrix(), PLearn::TinyVector< T, N, TTrait >::size(), PLearn::TinyVector< T, N, TTrait >::swap(), PLearn::TinyVector< T, N, TTrait >::TinyVector(), PLearn::BestAveragingPLearner::train(), PLearn::TopNI< T >::update(), and PLearn::BottomNI< T >::update().
Definition at line 14 of file test_pool.cc.
Referenced by alloc_from_pool().
1.7.4