Hi, I tested the memory pool, and I found that the performance of this memory pool is not good as allocating memory from heap, so the code is only for beginner to learn, right?
Allocate memory from memory pool: 0.304s
Allocate memory form heap: 0.0608
for(int i = 0; i < 200000; ++i) {
v = new TestMemoryPool();
}
template
float Test_Speed(int Times, _PRE bin) {
DWORD time1 = clock();
float count = 0;
while (count < Times) {
bin();
count++;
}
float elpstime = clock() - (float)time1;
auto total = count / (elpstime / 1000.0f);
printf("Speed: %0.0f/s\r\n", total);
return total;
}
I use this code to test runnning speed
but slower than new why cause that?
Hi, I tested the memory pool, and I found that the performance of this memory pool is not good as allocating memory from heap, so the code is only for beginner to learn, right?
Allocate memory from memory pool: 0.304s Allocate memory form heap: 0.0608
for(int i = 0; i < 200000; ++i) { v = new TestMemoryPool(); }