DavidLiRemini / MemoryPool

简单有效的内存池实现
90 stars 45 forks source link

Performance issue #3

Open tbabm93 opened 2 years ago

tbabm93 commented 2 years ago

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(); }

12UE commented 1 year ago

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?