int main() { const uint32_t length = 256; std::vector<Obj4> os4(length), os4d(length); std::vector<Obj8> os8(length), os8d(length); std::vector<Obj16> os16(length), os16d(length); std::vector<Obj32> os32(length), os32d(length); std::vector<Obj64> os64(length), os64d(length); benchmark_fun("obj 4", [&](uint32_t i) { return os4d[i] = os4[i]; }, length); benchmark_fun("obj 8", [&](uint32_t i) { return os8d[i] = os8[i]; }, length); benchmark_fun("obj 16", [&](uint32_t i) { return os16d[i] = os16[i]; }, length); benchmark_fun("obj 32", [&](uint32_t i) { return os32d[i] = os32[i]; }, length); benchmark_fun("obj 64", [&](uint32_t i) { return os64d[i] = os64[i]; }, length); return 0; }
int main() { const uint32_t length = 128; benchmark_fun("high_resolution_clock", [&](uint32_t) { return std::chrono::high_resolution_clock::now(); }, length); benchmark_fun("system_clock", [&](uint32_t) { return std::chrono::system_clock::now(); }, length); benchmark_fun("steady_clock", [&](uint32_t) { return std::chrono::steady_clock::now(); }, length); benchmark_fun("clock_gettime CLOCK_REALTIME", [&](uint32_t) { struct timespec tp; ::clock_gettime(CLOCK_REALTIME, &tp); return tp; }, length); benchmark_fun("clock_gettime CLOCK_MONOTONIC", [&](uint32_t) { struct timespec tp; ::clock_gettime(CLOCK_MONOTONIC, &tp); return tp; }, length); benchmark_fun("clock_gettime CLOCK_PROCESS_CPUTIME_ID", [&](uint32_t) { struct timespec tp; ::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tp); return tp; }, length); benchmark_fun("clock_gettime CLOCK_THREAD_CPUTIME_ID", [&](uint32_t) { struct timespec tp; ::clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp); return tp; }, length); return 0; }
int main (int argc, char *argv[]) { timer *t = timer_alloc(); // brk/sbrk recorder *stack_rec = recorder_alloc("stack.csv"); recorder *heap_rec = recorder_alloc("heap.csv"); benchmark_fun(t, heap_1, heap_rec, SIZE_1); benchmark_fun(t, heap_2, heap_rec, SIZE_2); benchmark_fun(t, heap_3, heap_rec, SIZE_3); benchmark_fun(t, stack_1, stack_rec, SIZE_1); benchmark_fun(t, stack_2, stack_rec, SIZE_2); benchmark_fun(t, stack_3, stack_rec, SIZE_3); printf("%p\n", sbrk(0)); recorder_free(stack_rec); recorder_free(heap_rec); timer_free(t); return EXIT_SUCCESS; }