aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/image.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2022-03-07 15:06:00 +0100
committerThomas White <taw@physics.org>2022-03-07 16:05:11 +0100
commitaa6ac7378542a1fe3ab6924b63c3ec9c1155dc2c (patch)
tree8682f7cdbe445b12d364346b855e7b204eaf4f61 /libcrystfel/src/image.c
parent19b57c06602e1fded39c1ad6234104d6d6e63114 (diff)
Add image_read_with_time_accounting for fine-grained data load profiling
Diffstat (limited to 'libcrystfel/src/image.c')
-rw-r--r--libcrystfel/src/image.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index c86439d8..3a8fb482 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -42,6 +42,7 @@
#include "image-hdf5.h"
#include "image-cbf.h"
#include "image-msgpack.h"
+#include "time-accounts.h"
#include "datatemplate.h"
#include "datatemplate_priv.h"
@@ -1267,28 +1268,35 @@ struct image *image_create_for_simulation(const DataTemplate *dtempl)
static int do_image_read(struct image *image, const DataTemplate *dtempl,
- int no_image_data, int no_mask_data)
+ int no_image_data, int no_mask_data,
+ TimeAccounts *taccs)
{
int i;
/* Load the image data */
+ time_accounts_set(taccs, TACC_IMAGE_DATA);
if ( !no_image_data ) {
if ( image_read_image_data(image, dtempl) ) return 1;
} else {
if ( image_set_zero_data(image, dtempl) ) return 1;
}
+ time_accounts_set(taccs, TACC_IMAGE_PARAMS);
if ( set_image_parameters(image, dtempl) ) {
ERROR("Failed to read image parameters\n");
return 1;
}
+ time_accounts_set(taccs, TACC_CREATE_DETGEOM);
if ( create_detgeom(image, dtempl) ) {
ERROR("Failed to read geometry information\n");
return 1;
}
+ time_accounts_set(taccs, TACC_CREATE_BADMAP);
if ( create_badmap(image, dtempl, no_mask_data) ) return 1;
+ time_accounts_set(taccs, TACC_CREATE_SATMAP);
if ( create_satmap(image, dtempl) ) return 1;
+ time_accounts_set(taccs, TACC_CACHE_HEADERS);
for ( i=0; i<dtempl->n_headers_to_copy; i++ ) {
read_header_to_cache(image, dtempl->headers_to_copy[i]);
}
@@ -1297,11 +1305,12 @@ static int do_image_read(struct image *image, const DataTemplate *dtempl,
}
-struct image *image_read(const DataTemplate *dtempl,
- const char *filename,
- const char *event,
- int no_image_data,
- int no_mask_data)
+struct image *image_read_with_time_accounting(const DataTemplate *dtempl,
+ const char *filename,
+ const char *event,
+ int no_image_data,
+ int no_mask_data,
+ TimeAccounts *taccs)
{
struct image *image;
@@ -1327,7 +1336,7 @@ struct image *image_read(const DataTemplate *dtempl,
image->data_source_type = file_type(image->filename);
- if ( do_image_read(image, dtempl, no_image_data, no_mask_data) ) {
+ if ( do_image_read(image, dtempl, no_image_data, no_mask_data, taccs) ) {
image_free(image);
return NULL;
}
@@ -1336,6 +1345,18 @@ struct image *image_read(const DataTemplate *dtempl,
}
+struct image *image_read(const DataTemplate *dtempl,
+ const char *filename,
+ const char *event,
+ int no_image_data,
+ int no_mask_data)
+{
+ return image_read_with_time_accounting(dtempl, filename, event,
+ no_image_data, no_mask_data,
+ NULL);
+}
+
+
struct image *image_read_data_block(const DataTemplate *dtempl,
void *data_block,
size_t data_block_size,
@@ -1366,7 +1387,7 @@ struct image *image_read_data_block(const DataTemplate *dtempl,
image->data_source_type = type;
- if ( do_image_read(image, dtempl, no_image_data, no_mask_data) ) {
+ if ( do_image_read(image, dtempl, no_image_data, no_mask_data, NULL) ) {
image_free(image);
ERROR("Failed to load image\n");
return NULL;