diff options
author | tlatorre <tlatorre@uchicago.edu> | 2018-08-31 09:44:06 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2018-08-31 09:44:06 -0500 |
commit | 460e841fa7238fd7a55ec77d91a105cf014c0978 (patch) | |
tree | 8d12b6e0de565f172d7a5a3e90fc99c575ecaefb /src/fit.c | |
parent | 22543102cea56e82fca4f6c1f6a20e9274e427cf (diff) | |
download | sddm-460e841fa7238fd7a55ec77d91a105cf014c0978.tar.gz sddm-460e841fa7238fd7a55ec77d91a105cf014c0978.tar.bz2 sddm-460e841fa7238fd7a55ec77d91a105cf014c0978.zip |
print out how long the likelihood function takes
Diffstat (limited to 'src/fit.c')
-rw-r--r-- | src/fit.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -11,6 +11,7 @@ #include "dqxx.h" #include <nlopt.h> #include <math.h> /* for sin(), cos(), etc. */ +#include <sys/time.h> /* 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; } |