Skip to content

Commit

Permalink
core: play with mesh object capacities
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed Nov 7, 2017
1 parent a058aa3 commit 86c120b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/builders/MeshPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace builders {
/// Provides the way to use pool of meshes instead of
/// building them each time which might be expensive.
class MeshPool final {
const std::size_t ThresholdSize = 1024 * 10;
const std::size_t ThresholdSize = 1024 * 10 * 2;
public:

MeshPool() {}
Expand Down
13 changes: 7 additions & 6 deletions core/test/builders/MeshPoolTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ using namespace utymap::builders;
using namespace utymap::math;

namespace {
const std::size_t BigSize = 10240 + 1024;
const std::size_t SmallSize = 4096 + 2;
const std::size_t BigSize = 10240 * 2 + 1024;

void addMesh(MeshPool &pool, std::size_t capacity) {

Expand Down Expand Up @@ -39,17 +40,17 @@ BOOST_AUTO_TEST_CASE(GivenEmptyPool_WhenGetLarge_ThenMeshReturned) {

BOOST_AUTO_TEST_CASE(GivenPoolWithTwoObjects_WhenGetSmall_ThenSmallestReturned) {
MeshPool pool;
addMesh(pool, 1024);
addMesh(pool, SmallSize);
addMesh(pool, BigSize);

auto mesh = pool.getSmall("my_name");

BOOST_CHECK_EQUAL(mesh.vertices.capacity(), 1024);
BOOST_CHECK_EQUAL(mesh.vertices.capacity(), SmallSize);
}

BOOST_AUTO_TEST_CASE(GivenPoolWithTwoObjects_WhenGetLarge_ThenLargestReturned) {
MeshPool pool;
addMesh(pool, 1024);
addMesh(pool, SmallSize);
addMesh(pool, BigSize);

auto mesh = pool.getLarge("my_name");
Expand All @@ -71,12 +72,12 @@ BOOST_AUTO_TEST_CASE(GivenEmptyPoolAfterRelease_WhenGetLarge_ThenMeshReturned) {
BOOST_AUTO_TEST_CASE(GivenEmptyPoolAfterRelease_WhenGetSmall_ThenMeshReturned) {
MeshPool pool;
Mesh mesh("");
mesh.vertices.resize(1024);
mesh.vertices.resize(SmallSize);
pool.release(std::move(mesh));

auto result = pool.getSmall("my_name");

BOOST_CHECK_EQUAL(result.vertices.capacity(), 1024);
BOOST_CHECK_EQUAL(result.vertices.capacity(), SmallSize);
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 86c120b

Please sign in to comment.