From 297d9c53f3d6323197bdc94873b0b88391fbcd1b Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sat, 25 Nov 2023 18:25:53 +0000 Subject: [PATCH] Fix repetition tester --- haversine_02/src/repetition_testing/main.cpp | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/haversine_02/src/repetition_testing/main.cpp b/haversine_02/src/repetition_testing/main.cpp index c168108..8da4980 100644 --- a/haversine_02/src/repetition_testing/main.cpp +++ b/haversine_02/src/repetition_testing/main.cpp @@ -63,9 +63,11 @@ int main(int argc, char *argv[]) { return -1; } - func_data funcs[] = {{{"WRITE", "WRITE WITH MALLOC"}, test_write}, - {{"READ", "READ WITH MALLOC"}, test_read}, - {{"FREAD", "FREAD WITH MALLOC"}, test_fread}}; + func_data funcs[] = { + {{"WRITE", "WRITE WITH MALLOC"}, test_write}, + {{"READ", "READ WITH MALLOC"}, test_read}, + {{"FREAD", "FREAD WITH MALLOC"}, test_fread}, + }; tester.params.read_size = get_file_length(fp); tester.params.read_count = 1; @@ -93,11 +95,11 @@ void test_fread(reptester *tester, alloc_type type) { return; } - handle_alloc(tester, type); - u64 start = read_cpu_timer(); u64 fault_count_start = page_fault_count(); + handle_alloc(tester, type); + u64 obj_count = fread(tester->params.buffer, tester->params.read_size, tester->params.read_count, fp); @@ -126,13 +128,13 @@ void test_read(reptester *tester, alloc_type type) { return; } + u64 start = read_cpu_timer(); + u64 fault_count_start = page_fault_count(); + handle_alloc(tester, type); i32 fd = fileno(fp); - u64 start = read_cpu_timer(); - u64 fault_count_start = page_fault_count(); - u64 bytes_read = read(fd, tester->params.buffer, tester->params.read_size * tester->params.read_count); @@ -154,11 +156,11 @@ void test_read(reptester *tester, alloc_type type) { } void test_write(reptester *tester, alloc_type type) { - handle_alloc(tester, type); - u64 start = read_cpu_timer(); u64 fault_count_start = page_fault_count(); + handle_alloc(tester, type); + u64 total_size = tester->params.read_size * tester->params.read_count; for (u64 i = 0; i < total_size; ++i) {