#include static int64_t accumulator = 0; #define ITERS 1000000000 int64_t reset(int64_t val) { int64_t temp = accumulator; accumulator = val; return temp; } __attribute__((noinline)) int64_t one(int64_t a) { accumulator += a; return accumulator; } __attribute__((noinline)) int64_t two(int64_t a, int64_t b) { accumulator += a; accumulator += b; return accumulator; } __attribute__((noinline)) int64_t three(int64_t a, int64_t b, int64_t c) { accumulator += a; accumulator += b; accumulator += c; return accumulator; } __attribute__((noinline)) int64_t four(int64_t a, int64_t b, int64_t c, int64_t d) { accumulator += a; accumulator += b; accumulator += c; accumulator += d; return accumulator; } __attribute__((noinline)) int64_t five(int64_t a, int64_t b, int64_t c, int64_t d, int64_t e) { accumulator += a; accumulator += b; accumulator += c; accumulator += d; accumulator += e; return accumulator; } __attribute__((noinline)) int64_t six(int64_t a, int64_t b, int64_t c, int64_t d, int64_t e, int64_t f) { accumulator += a; accumulator += b; accumulator += c; accumulator += d; accumulator += e; accumulator += f; return accumulator; } __attribute__((noinline)) int64_t seven(int64_t a, int64_t b, int64_t c, int64_t d, int64_t e, int64_t f, int64_t g) { accumulator += a; accumulator += b; accumulator += c; accumulator += d; accumulator += e; accumulator += f; accumulator += g; return accumulator; } __attribute__((noinline)) int64_t eight(int64_t a, int64_t b, int64_t c, int64_t d, int64_t e, int64_t f, int64_t g, int64_t h) { accumulator += a; accumulator += b; accumulator += c; accumulator += d; accumulator += e; accumulator += f; accumulator += g; accumulator += h; return accumulator; } #define BENCH(func, args) \ int64_t bench_##func(void) { \ for (int64_t i = 0; i < ITERS; i++) { \ func args; \ } \ return accumulator; \ } BENCH(one, (accumulator)) BENCH(two, (accumulator, accumulator + 1)) BENCH(three, (accumulator, accumulator + 1, accumulator + 2)) BENCH(four, (accumulator, accumulator + 1, accumulator + 2, accumulator + 3)) BENCH(five, (accumulator, accumulator + 1, accumulator + 2, accumulator + 3, accumulator + 4)) BENCH(six, (accumulator, accumulator + 1, accumulator + 2, accumulator + 3, accumulator + 4, accumulator + 5)) BENCH(seven, (accumulator, accumulator + 1, accumulator + 2, accumulator + 3, accumulator + 4, accumulator + 5, accumulator + 6)) BENCH(eight, (accumulator, accumulator + 1, accumulator + 2, accumulator + 3, accumulator + 4, accumulator + 5, accumulator + 6, accumulator + 7)) int main(int argc, const char **argv) { return 0; }