Skip to content

[Portuguese] METRIC_CALL

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

Este macro chama uma função repetidas vezes e exibe o menor tempo medido para rodar a função. Conforme o exemplo:

#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;
}

Saída:

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