Skip to content
Snippets Groups Projects
Commit fe63e89f authored by j2-tulloch's avatar j2-tulloch :speech_balloon:
Browse files

Upload New File

parent afd26b08
Branches
No related tags found
No related merge requests found
#include <chrono>
#include <iostream>
#include "bumpalld.hpp"
//#include "bumpall.hpp"
void benchmarkBumpAllocator() {
const size_t blockSize = 1000000; // Size of the memory block
BumpAllocator allocator(blockSize);
// Example allocation/deallocation operations
for (int i = 0; i < 10000; ++i) {
allocator.allocate(100); // Allocate 100 bytes
allocator.reset(); // Reset the allocator for the next iteration
}
}
int main() {
using std::chrono::high_resolution_clock;
using std::chrono::duration_cast;
using std::chrono::duration;
using std::chrono::milliseconds;
auto t1 = high_resolution_clock::now();
benchmarkBumpAllocator();
auto t2 = high_resolution_clock::now();
auto ms_int = duration_cast<milliseconds>(t2 - t1);
duration<double, std::milli> ms_double = t2 - t1;
std::cout << ms_int.count() << "ms\n";
std::cout << ms_double.count() << "ms\n";
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment