diff options
author | Camil Staps | 2015-12-04 16:40:16 +0100 |
---|---|---|
committer | Camil Staps | 2015-12-04 16:40:16 +0100 |
commit | fd0c013f914f47b040d937c293fccac5e5224208 (patch) | |
tree | c2764c571160f9a27605eb00e9442f44a0704e8c /minctest.c | |
parent | Include guard (diff) |
Timing
Diffstat (limited to 'minctest.c')
-rw-r--r-- | minctest.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -31,6 +31,7 @@ tester* test_initialize(void) { test->passed = 0; test->failed = 0; test->show_pass = true; + test_start_timer(test); return test; } @@ -53,15 +54,25 @@ void test_exit(tester* tester) { exit(all_passed ? 0 : -1); } +void test_start_timer(tester* tester) { + gettimeofday(&tester->start_last_test, NULL); +} + void test_true(tester* tester, bool check, const char* text) { + struct timeval end; + gettimeofday(&end, NULL); + if (!check || tester->show_pass) { printf(check ? KGRN : KRED); printf(check ? "Test passed" : "Test failed"); if (text != NULL) printf(": %s", text); + printf(" [%.3fs]", ((float) end.tv_usec - tester->start_last_test.tv_usec) / 1000); printf("\n" RESET); } *(check ? &tester->passed : &tester->failed) += 1; + + test_start_timer(tester); } |