Skip to content

[English] METRIC_CALL

Luiz Felipe edited this page Aug 21, 2021 · 4 revisions
METRIC_CALL(times, function, args...)

This macro call a function repeated times and show the minimum measured time to run the function. Like the example below:

#include <stdio.h>
#include "metric.h"

void example(char *msg, int n)
{
  sprintf(msg, "|%d|", n);
}

int main(void)
{
  char test[64];
  METRIC_CALL(10000, example, test, 456);
  return 0;
}

Output:

<BENCH> tst.c: example(test, 456) x 10000
        92 clocks, 0.00009000 secs