From c64ea8db135af2d541d56f6bd1ebb689e7915589 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 12 Jul 2019 12:05:38 +0200 Subject: (#143) Rajout de la macro TIMEINIT --- test/monniaux/cycles.h | 1 + test/monniaux/sandbox/example.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/monniaux/cycles.h b/test/monniaux/cycles.h index f072e479..c7978ff4 100644 --- a/test/monniaux/cycles.h +++ b/test/monniaux/cycles.h @@ -43,6 +43,7 @@ static inline cycle_t get_cycle(void) { return 0; } #endif #ifdef MAX_MEASURES + #define TIMEINIT {_last_stop = get_cycle();} #define TIMESTOP(i) {cycle_t cur = get_cycle(); _total_cycles[i] += cur - _last_stop; _last_stop = cur;} #define TIMEPRINT(n) { for (int i = 0; i <= n; i++) printf("(%d) cycles: %" PRIu64 "\n", i, _total_cycles[i]); } #endif diff --git a/test/monniaux/sandbox/example.c b/test/monniaux/sandbox/example.c index 4fec922d..dccb576e 100644 --- a/test/monniaux/sandbox/example.c +++ b/test/monniaux/sandbox/example.c @@ -8,15 +8,15 @@ int main(void){ int i; int S = 0; - TIMESTOP(0) + TIMEINIT for (i = 0; i < 1000; i++){ S += f(i, i*2); } - TIMESTOP(1) + TIMESTOP(0) printf("Final value: %d\n", S); - TIMESTOP(2) + TIMESTOP(1) - TIMEPRINT(2) + TIMEPRINT(1) return 0; } -- cgit