Easy-to-use single file header only performance comparator for C++ (cpp11 or later)
include "ezbench.hpp"
void vecAdd(std::vector<TestStruct>& vec, uint32_t add_count)
{
for (int i(add_count); i--;)
{
vec->push_back(TestStruct());
}
}
Using a very simple test structure
struct TestStruct
{
double useless[20];
TestStruct() = default;
};
std::vector<TestStruct> vec;
std::list<TestStruct> list;
uint8_t iteration_count = 1;
uint32_t objects_count = 1000000;
ezb::Benchmark bench{
iteration_count, // Not implemented yet, set it to 1
{
{"Insertion", // Test 1
{
{"Vector", std::bind(vecAdd, vec, objects_count)},
{"List", std::bind(listAdd, list, objects_count)}
}
},
{"Iteration", // Test 2
{
{"Vector", std::bind(vecIter, vec)},
{"List", std::bind(listIter, list)}
}
},
{"Deletion", // Test 3
{
{"Vector", std::bind(vecDel, vec)},
{"List", std::bind(listDel, list)}
}
}
}
};
-----[ Insertion ]-----
List 196.335 ms (100 % -> x1)
Vector 401.454 ms (204 % -> x2)
-----[ Iteration ]-----
Vector 11.769 ms (100 % -> x1)
List 63.3059 ms (537 % -> x5)
-----[ Deletion ]-----
List 63.6138 ms (100 % -> x1)
Vector 1355.97 ms (2131 % -> x21)
- Add metric configuration (only ms for now)
- Implement multi iterations support with stats