diff options
author | Thomas White <taw@physics.org> | 2022-05-06 12:02:54 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2022-06-02 12:15:38 +0200 |
commit | 27d4992f755279a2240059c9cd67f737af0481a2 (patch) | |
tree | 8bde4f5566a2abfbe0f1ea54325a45523d7309c6 | |
parent | 610f1778b9d4da641ba3fede8326b78d4088ee93 (diff) |
Add worker ID to profiling data
-rw-r--r-- | libcrystfel/src/profile.c | 10 | ||||
-rw-r--r-- | libcrystfel/src/profile.h | 2 | ||||
-rw-r--r-- | src/im-sandbox.c | 2 |
3 files changed, 8 insertions, 6 deletions
diff --git a/libcrystfel/src/profile.c b/libcrystfel/src/profile.c index 79228b34..82f0217f 100644 --- a/libcrystfel/src/profile.c +++ b/libcrystfel/src/profile.c @@ -166,7 +166,7 @@ static void free_profile_block(struct _profile_block *b) } -void profile_print_and_reset() +void profile_print_and_reset(int worker_id) { char *buf; char *buf2; @@ -187,10 +187,12 @@ void profile_print_and_reset() stop_profile_block(pd->root); buf = format_profile_block(pd->root); - buf2 = malloc(2+strlen(buf)); - strcpy(buf2, buf); - strcat(buf2, "\n"); + buf2 = malloc(8+strlen(buf)); + size_t len = 8+strlen(buf); + snprintf(buf2, len, "%i %s\n", worker_id, buf); write(STDOUT_FILENO, buf2, strlen(buf2)); + free(buf); + free(buf2); free_profile_block(pd->root); pd->root = start_profile_block("root"); diff --git a/libcrystfel/src/profile.h b/libcrystfel/src/profile.h index 183528ce..61ef20c3 100644 --- a/libcrystfel/src/profile.h +++ b/libcrystfel/src/profile.h @@ -35,7 +35,7 @@ */ extern void profile_init(); -extern void profile_print_and_reset(); +extern void profile_print_and_reset(int worker_id); extern void profile_start(const char *name); extern void profile_end(const char *name); diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 8e1e5004..4337e4a2 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -526,7 +526,7 @@ static int run_work(const struct index_args *iargs, Stream *st, * eventually be freed by image_free() under process_image(). */ if ( sb->profile ) { - profile_print_and_reset(); + profile_print_and_reset(cookie); } } |