I wanted to test how fast memmove can move bytes.
What would be the best way to do this?
I was thinking of using malloc to create 2 arrays (a source and a dest)
#include <time.h> #define MEM_SIZE_16MB ( 16 * 1024 * 1024 ) clock_t t; char *source = malloc(MEM_SIZE_16MB * sizeof(char)); char *dest = malloc(MEM_SIZE_16MB * sizeof(char)); t = clock(); memmove(dest, source, sizeof(source)) t = clock() - t; double time_taken = ((double)t)/CLOCKS_PER_SEC; double mbps = 16/time_taken; free(source); free(dest);
Would this be a good setup?
https://stackoverflow.com/questions/65866218/setup-to-test-the-mbps-of-memmove January 24, 2021 at 09:07AM
没有评论:
发表评论