It's encouraged to use STL over dynamic arrays but I'm curious what could be the bottleneck? MAX_PACKET_LENGTH
is 32768
.
---------------------------------------------------------------------------
Benchmark Time CPU Iterations
---------------------------------------------------------------------------
BM_VectorInit 1335 ns 1193 ns 497778
BM_RawInit 58 ns 55 ns 10000000
static void BM_VectorInit(benchmark::State &state)
{
for (auto _ : state)
{
std::vector<char> a(MAX_PACKET_LENGTH);
}
}
static void BM_RawInit(benchmark::State &state)
{
for (auto _ : state)
{
auto a = new char[MAX_PACKET_LENGTH];
delete[] a;
}
}