allocPool: Répare compilation sur Windows

This commit is contained in:
Timothée Leclaire-Fournier 2024-03-03 14:40:55 -05:00
parent 302c2a5f17
commit b0cbb7455b
2 changed files with 12 additions and 0 deletions

View File

@ -33,16 +33,27 @@ private:
int i = 15; int i = 15;
}; };
``` ```
On Linux:
``` ```
Time (milliseconds) required for allocations without pool: 21 Time (milliseconds) required for allocations without pool: 21
Time (milliseconds) required for allocations with pool: 3 Time (milliseconds) required for allocations with pool: 3
Time (milliseconds) required for real allocations when constructing pool: 9 Time (milliseconds) required for real allocations when constructing pool: 9
``` ```
On Windows:
```
Time (milliseconds) required for allocations without pool: 62
Time (milliseconds) required for allocations with pool: 6
Time (milliseconds) required for real allocations when constructing pool: 51
```
This trivial example shows some performance improvements that would be much more This trivial example shows some performance improvements that would be much more
important should the allocation and construction/destruction of the objects be more important should the allocation and construction/destruction of the objects be more
complex. complex.
In the case where the allocator is very fast (such as glibc's on Linux) this approach
may not be necessary, but in the case of slow allocators (such as Windows' default), it
could be interesting to consider such an approach.
## Safety ## Safety
AddressSanitizer, LeakSanitizer and ThreadSanitizer have been used to ensure the safety AddressSanitizer, LeakSanitizer and ThreadSanitizer have been used to ensure the safety
of the class. Tests have been added to ensure the correct behavior in all cases. of the class. Tests have been added to ensure the correct behavior in all cases.

View File

@ -5,6 +5,7 @@
#include <concepts> #include <concepts>
#include <cstddef> #include <cstddef>
#include <cstring> #include <cstring>
#include <mutex>
#include <thread> #include <thread>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>