From 460e841fa7238fd7a55ec77d91a105cf014c0978 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Fri, 31 Aug 2018 09:44:06 -0500 Subject: print out how long the likelihood function takes --- src/fit.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/fit.c') diff --git a/src/fit.c b/src/fit.c index 7deec9d..89e0c93 100644 --- a/src/fit.c +++ b/src/fit.c @@ -11,6 +11,7 @@ #include "dqxx.h" #include #include /* for sin(), cos(), etc. */ +#include /* for gettimeofday() */ #define EV_RECORD 0x45562020 // 'EV ' (as written to ZDAB file) @@ -21,6 +22,7 @@ double nll(unsigned int n, const double *x, double *grad, void *params) static size_t iter; double fval; double z1[1], z2[1]; + struct timeval tv_start, tv_stop; T = x[0]; @@ -39,9 +41,13 @@ double nll(unsigned int n, const double *x, double *grad, void *params) z1[0] = x[7]; z2[0] = x[8]; + gettimeofday(&tv_start, NULL); fval = nll_muon((event *) params, T, pos, dir, t0, z1, z2, 1); + gettimeofday(&tv_stop, NULL); - printf("%5zu %10.2f %7.2f %7.2f %7.2f %4.2f %4.2f %5.2f %4.2f %4.2f f() = %7.3e\n", + long long elapsed = (tv_stop.tv_sec - tv_start.tv_sec)*1000 + (tv_stop.tv_usec - tv_start.tv_usec)/1000; + + printf("%5zu %10.2f %7.2f %7.2f %7.2f %4.2f %4.2f %5.2f %4.2f %4.2f f() = %7.3e took %lld ms\n", iter++, x[0], x[1], @@ -52,7 +58,8 @@ double nll(unsigned int n, const double *x, double *grad, void *params) x[6], x[7], x[8], - fval); + fval, + elapsed); return fval; } -- cgit