Wednesday, 12 July 2017

How to count the exectution time inside of a function?

Use __builtin_readcyclecounter
like :

int foo(void) {
  int start = __builtin_readcyclecounter();
  CODE to be TESTED
 int end = __builtin_readcyclecounter();
 int diff = end - start
 printf(diff);
}

No comments:

Post a Comment