Created
October 28, 2019 12:29
-
-
Save joemccall86/c441119a88b88dcd2010068d9e557487 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <microtime.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int main(int argc, char **argv) | |
{ | |
int i, vector_size = 200000000; | |
float *vector1, *vector2; | |
double time1, time2; | |
/* allocate and set to zero */ | |
time1 = microtime(); | |
vector1 = calloc(vector_size, sizeof(float)); | |
time2 = microtime(); | |
printf("1. Time = %g us\tTimer Resolution = %g us\n", time2-time1, get_microtime_resolution()); | |
time1 = microtime(); | |
vector2 = malloc(vector_size * sizeof(float)); | |
for (i = 0; i < vector_size; ++i) { | |
vector2[i] = 0; | |
} | |
time2 = microtime(); | |
printf("2. Time = %g us\tTimer Resolution = %g us\n", time2-time1, get_microtime_resolution()); | |
/* cleanup */ | |
free(vector1); | |
free(vector2); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment