From f2679b82046b608358bd699e35eee959e623e554 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 27 May 2020 21:15:06 +0200 Subject: [PATCH] ex-2/fast: print running time --- ex-2/fast.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ex-2/fast.c b/ex-2/fast.c index 22a2b33..da72e7b 100644 --- a/ex-2/fast.c +++ b/ex-2/fast.c @@ -2,6 +2,7 @@ #include #include #include +#include /* The Euler-Mascheroni constant is here computed to * arbitrary precision using GMP floating point numbers @@ -216,7 +217,12 @@ int main(int argc, char** argv) { mpf_set_default_prec(prec + 64); mpf_t y; mpf_init(y); + + clock_t begin = clock(); mpf_gamma(y, digits); + clock_t end = clock(); + double time = (double)(end - begin)/CLOCKS_PER_SEC; + fprintf(stderr, "[main] running time: %gs\n", time); // again, trick to avoid rounding gmp_printf("%.*Ff\b \n", digits+1, y);