more verbosity in cache test

This commit is contained in:
Lenni Hein 2025-02-25 15:22:23 +01:00
parent 3799317456
commit b672bb0906

View File

@ -17,7 +17,7 @@ void measure_multiple_accesses(void (*addr)(void), size_t num_accesses, size_t*
}
}
size_t find_crossover_point(size_t* hits, size_t* misses, size_t num_accesses)
void find_crossover_point(size_t* hits, size_t* misses, size_t num_accesses)
{
size_t hit_sum = 0, miss_sum = 0;
@ -30,7 +30,11 @@ size_t find_crossover_point(size_t* hits, size_t* misses, size_t num_accesses)
size_t avg_hit = hit_sum / num_accesses;
size_t avg_miss = miss_sum / num_accesses;
return (avg_hit + avg_miss) / 2; // Midpoint as threshold
printf("Average hit time: %zu\n", avg_hit);
printf("Average miss time: %zu\n", avg_miss);
size_t threshold = (avg_hit + avg_miss) / 2; // Midpoint as threshold
printf("Midpoint: %zu\n", threshold);
}
int main()
@ -46,9 +50,7 @@ int main()
// We use the addr. of main for our test, but anything works.
measure_multiple_accesses((void*) main, NUM_ACCESSES, hits, misses);
size_t threshold = find_crossover_point(hits, misses, NUM_ACCESSES);
printf("Suggested threshold: %zu\n", threshold);
find_crossover_point(hits, misses, NUM_ACCESSES);
free(hits);
free(misses);