From 2a727e583bb038b0a93dde7e0d9a947135d61613 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Tue, 25 Feb 2020 19:59:32 +0100 Subject: [PATCH] Add time profiler to board solver example --- main.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 6a60793..19735eb 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "board.h" @@ -315,20 +316,27 @@ main (int argc, char **argv, char **env) print_board (root_board); - if (board_is_valid (root_board)) - printf ("Board is valid!\nBoard complexity: %u\n", root_board->complexity); - else - puts ("Board is invalid!"); + if (! board_is_valid (root_board)) + { + puts ("Supplied board is not valid!"); + return 1; + } puts("\nReducing..."); + + /* Profiler start time */ + time_t start; + time (&start); + simplify (&boards, 0); + /* Profiler end time */ + time_t end; + time (&end); + print_board (root_board); - if (board_is_valid (root_board)) - printf ("Board is valid!\nBoard complexity: %u\n", root_board->complexity); - else - puts ("Board is invalid!"); + printf ("Simplification took %llu seconds to complete\n", end - start); return 0; }