Skip to content

Instantly share code, notes, and snippets.

@paulodiogo
Last active April 1, 2021 18:39
Show Gist options
  • Save paulodiogo/73686adb0a00a5062addefb58aff957d to your computer and use it in GitHub Desktop.
Save paulodiogo/73686adb0a00a5062addefb58aff957d to your computer and use it in GitHub Desktop.
Medição de tempo em C++
#include <sys/time.h>
struct timespec begin;
clock_gettime(CLOCK_MONOTONIC, &begin);
{
//RODAR METODO AQUI
}
struct timespec end;
clock_gettime(CLOCK_MONOTONIC, &end);
double time_spent = double(end.tv_sec - begin.tv_sec) + (end.tv_nsec - begin.tv_nsec) / 1000000000.0; // segundos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment