#include <time.h>

int delay(int time)
{
    int i,j;
    
    for(i =0;i<time;i++)
        for(j=0;j<10000;j++)
            ;
}

int main()
{
        struct timespec start_1, end_1;
        unsigned  long long diff;

        clock_gettime(CLOCK_REALTIME, &start_1);

        delay(10);    // UUT unit under test

        clock_gettime(CLOCK_REALTIME, &end_1);

        diff = 1000000000 * (end_1.tv_sec - start_1.tv_sec) + (end_1.tv_nsec - start_1.tv_nsec);
        printf("the difference is %lld nano seconds\n",diff);
        
        return 0;
}

reference : too much

相关文章:

  • 2021-12-14
  • 2021-08-01
  • 2021-10-30
  • 2021-12-03
  • 2021-08-22
  • 2022-01-07
  • 2021-05-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2021-10-22
  • 2021-07-24
  • 2022-01-07
  • 2021-10-11
相关资源
相似解决方案