Python
import time
start = time.time()
# tasks
end = time.time()
print(end-start,"s")
C++ (Cuda)
#include <sys/time.h>
struct timeval start, end;
gettimeofday( &start, NULL );
# tasks
gettimeofday( &end, NULL );
int timeuse = 1000000 * ( end.tv_sec - start.tv_sec ) + end.tv_usec - start.tv_usec;
printf("total time is %d ms\n", timeuse/1000);