I was trying to compare c and cython runtime and decide on which one should I choose for my project. So I tested a simple calculation with both. but I couldn't find any good answer to how to measure cython execute time to compare with c:
C :
#include <stdio.h>
#include <time.h>
int main() {
int a[3] = {2, 3, 4};
long long int n = 0;
clock_t start, end;
double cpu_time_used;
start = clock();
for(long long int i=0; i<1000000000; i++)
n += a[0] + a[2];
end = clock();
cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
printf("time : %f", cpu_time_used);
return 0;
}
Cython :
cpdef func():
cdef int arr[3]
arr[:] = [2, 3, 4]
cdef unsigned long long a = 0, i
for i in range(1000000000):
a += arr[0] + arr[2]
return a
I want to know how to compare execute time of cython?