#include <time.h> /* return current time in milliseconds */ long get_current_ms() { struct timespec res; clock_gettime(CLOCK_REALTIME, &res); return 1000 * res.tv_sec + res.tv_nsec / 1e6; }
那么可以这样调用了:
long start = get_current_ms(); // start time // YOUR CODE HERE long end = get_current_ms(); // end time long delta = end - start; // time your code took to exec in ms
时间: 2024-09-30 11:14:52