mirror of
https://github.com/recp/cglm.git
synced 2025-10-03 16:51:35 +00:00
tests: print elapsed time to run a test
This commit is contained in:
@@ -9,12 +9,14 @@
|
|||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, const char * argv[]) {
|
main(int argc, const char * argv[]) {
|
||||||
test_entry_t *entry;
|
test_entry_t *entry;
|
||||||
test_status_t st;
|
test_status_t st;
|
||||||
int32_t i, count, passed, failed;
|
int32_t i, count, passed, failed;
|
||||||
|
double start, end, elapsed;
|
||||||
|
|
||||||
passed = failed = 0;
|
passed = failed = 0;
|
||||||
count = sizeof(tests) / sizeof(tests[0]);
|
count = sizeof(tests) / sizeof(tests[0]);
|
||||||
@@ -22,8 +24,11 @@ main(int argc, const char * argv[]) {
|
|||||||
fprintf(stderr, CYAN "\nWelcome to cglm tests\n\n" RESET);
|
fprintf(stderr, CYAN "\nWelcome to cglm tests\n\n" RESET);
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
entry = tests + i;
|
entry = tests + i;
|
||||||
st = entry->entry();
|
start = clock();
|
||||||
|
st = entry->entry();
|
||||||
|
end = clock();
|
||||||
|
elapsed = (end - start) / CLOCKS_PER_SEC;
|
||||||
|
|
||||||
if (!st.status) {
|
if (!st.status) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -39,10 +44,14 @@ main(int argc, const char * argv[]) {
|
|||||||
|
|
||||||
failed++;
|
failed++;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr, GREEN " ✔︎" RESET " %s - " , entry->name);
|
||||||
GREEN " ✔︎" RESET " %s\n"
|
|
||||||
,
|
if (elapsed > 0.01)
|
||||||
entry->name);
|
fprintf(stderr, YELLOW "%.2f", elapsed);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "0");
|
||||||
|
|
||||||
|
fprintf(stderr, "s\n" RESET);
|
||||||
passed++;
|
passed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +67,7 @@ main(int argc, const char * argv[]) {
|
|||||||
MAGENTA "%d" RESET " tests are runned, "
|
MAGENTA "%d" RESET " tests are runned, "
|
||||||
GREEN "%d" RESET " %s passed, "
|
GREEN "%d" RESET " %s passed, "
|
||||||
RED "%d" RESET " %s failed\n\n" RESET,
|
RED "%d" RESET " %s failed\n\n" RESET,
|
||||||
passed + failed,
|
count,
|
||||||
passed,
|
passed,
|
||||||
passed > 1 ? "are" : "is",
|
passed > 1 ? "are" : "is",
|
||||||
failed,
|
failed,
|
||||||
|
Reference in New Issue
Block a user