add write bytes backward test
This commit is contained in:
parent
da9af2ff49
commit
ba3d3cabcb
@ -12,6 +12,7 @@
|
||||
#include "main_write_bytes_asm.c"
|
||||
#include "main_write_all_bytes.c"
|
||||
#include "main_malloc_read.c"
|
||||
#include "main_write_backward.c"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc < 2) {
|
||||
@ -25,6 +26,8 @@ int main(int argc, char **argv) {
|
||||
return main_test_write_bytes_asm();
|
||||
} else if (!strncmp(test_name, "write_all_bytes", sizeof("write_bytes"))) {
|
||||
return main_test_write_all_bytes();
|
||||
} else if (!strncmp(test_name, "write_backward", sizeof("write_backward"))) {
|
||||
return main_test_write_backward();
|
||||
} else if (!strncmp(test_name, "read_file", sizeof("read_file"))) {
|
||||
if (argc < 3) {
|
||||
printf("Usage: %s read_file <filename>\n", argv[0]);
|
||||
|
@ -20,7 +20,6 @@ static void test_write_to_all_bytes(struct repetitor *repetitor, uint8_t *buffer
|
||||
}
|
||||
|
||||
int main_test_write_all_bytes() {
|
||||
|
||||
struct repetitor repetitor = {};
|
||||
repetitor_init(&repetitor);
|
||||
printf("CPU Frequency: %ldHz (~%.2fGHz)\n", repetitor.cpu_freq, (float)repetitor.cpu_freq/(1000*1000*1000));
|
||||
|
41
src/main_write_backward.c
Normal file
41
src/main_write_backward.c
Normal file
@ -0,0 +1,41 @@
|
||||
#include "repetition_tester.c"
|
||||
|
||||
int main_test_write_backward() {
|
||||
struct repetitor repetitor = {};
|
||||
repetitor_init(&repetitor);
|
||||
printf("CPU Frequency: %ldHz (~%.2fGHz)\n", repetitor.cpu_freq, (float)repetitor.cpu_freq/(1000*1000*1000));
|
||||
|
||||
uint64_t byte_count = 4096 * (1024 * 8);
|
||||
|
||||
while (repeat_cycle_times(&repetitor, 3)) {
|
||||
repetitor_clear(&repetitor);
|
||||
while (repetitor_repeat(&repetitor, 2)) {
|
||||
repetitor_start(&repetitor);
|
||||
uint8_t *buffer = malloc(sizeof(uint8_t) * byte_count);
|
||||
repetitor_measure_start(&repetitor);
|
||||
for (int i = 0; i < byte_count; i++) {
|
||||
buffer[i] = (uint8_t)i;
|
||||
}
|
||||
repetitor_measure_stop(&repetitor, byte_count);
|
||||
free(buffer);
|
||||
repetitor_stop(&repetitor);
|
||||
}
|
||||
repetitor_print_results_label(&repetitor, "write forward");
|
||||
|
||||
repetitor_clear(&repetitor);
|
||||
while (repetitor_repeat(&repetitor, 2)) {
|
||||
repetitor_start(&repetitor);
|
||||
uint8_t *buffer = malloc(sizeof(uint8_t) * byte_count);
|
||||
repetitor_measure_start(&repetitor);
|
||||
for (int i = 0; i < byte_count; i++) {
|
||||
buffer[byte_count - i - 1] = (uint8_t)i;
|
||||
}
|
||||
repetitor_measure_stop(&repetitor, byte_count);
|
||||
free(buffer);
|
||||
repetitor_stop(&repetitor);
|
||||
}
|
||||
repetitor_print_results_label(&repetitor, "write backward");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user