Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Just a silly short list sum script to provide as a baseline for benchmarking Swift code.
// clang -O3 -march=native deleteme.c -o del_c
#include <stdio.h>
#include <time.h>
int main () {
clock_t start, end;
double cpu_time_used;
int n[ 3000 ];
for (int tests = 0; tests < 15; tests++) {
start = clock();
int sum = 0;
for (int i = 0; i < 3000; i++) {
n[i] = tests;
}
for(int i=0; i<3000; i++) {
sum = sum + n[i];
}
end = clock();
cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
printf("%.6f", cpu_time_used);
printf(" %d", sum);
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.