diff options
author | Thomas White <taw@physics.org> | 2020-09-09 15:40:47 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-09-09 15:40:47 +0200 |
commit | 8f859bd6f03a7f8e62563bbf052eb4595a522b9d (patch) | |
tree | 4b2e36d302cd07714deae07c2b8722d70ea5b136 /libcrystfel/src/index.c | |
parent | 74d4bb6cf67454884447a2f7b9bc94f9e6b2ae08 (diff) |
Add optional measurement of time spent in indexers
Diffstat (limited to 'libcrystfel/src/index.c')
-rw-r--r-- | libcrystfel/src/index.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 836901ff..9c90c164 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -627,6 +627,16 @@ static int check_cell(IndexingFlags flags, Crystal *cr, UnitCell *target, } +#ifdef MEASURE_INDEX_TIME +static float real_time() +{ + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC_RAW, &tp); + return tp.tv_sec + tp.tv_nsec*1e-9; +} +#endif + + /* Return non-zero for "success" */ static int try_indexer(struct image *image, IndexingMethod indm, IndexingPrivate *ipriv, void *mpriv, char *last_task) @@ -635,6 +645,12 @@ static int try_indexer(struct image *image, IndexingMethod indm, int n_bad = 0; int n_before = image->n_crystals; + #ifdef MEASURE_INDEX_TIME + float time_start; + float time_end; + time_start = real_time(); + #endif + switch ( indm & INDEXING_METHOD_MASK ) { case INDEXING_NONE : @@ -693,6 +709,13 @@ static int try_indexer(struct image *image, IndexingMethod indm, set_last_task(last_task, "indexing:finalisation"); + #ifdef MEASURE_INDEX_TIME + time_end = real_time(); + printf("%s took %f s, %i crystals found, %s %s\n", + indexer_str(indm & INDEXING_METHOD_MASK), + time_end - time_start, r, image->filename, image->ev); + #endif + /* Stop a really difficult to debug situation in its tracks */ if ( image->n_crystals - n_before != r ) { ERROR("Whoops, indexer didn't return the right number " |