aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-12-07 17:15:04 +0100
committerThomas White <taw@physics.org>2021-12-07 17:20:18 +0100
commit0c5f4739df52f8cf1782d7a608dfa49336e94844 (patch)
treea50f4b2d0afc99f3d4fa60c8de55ac3f5886768b /src
parentfe938a0ad2af037fff80114ca2832d41dc48e55e (diff)
indexamajig: Generate per-frame profiling numbers
Diffstat (limited to 'src')
-rw-r--r--src/im-sandbox.c16
-rw-r--r--src/time-accounts.c50
-rw-r--r--src/time-accounts.h3
3 files changed, 63 insertions, 6 deletions
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index 9724c245..9115cb1b 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -329,7 +329,6 @@ static int run_work(const struct index_args *iargs, Stream *st,
int cookie, const char *tmpdir, struct sandbox *sb)
{
int allDone = 0;
- TimeAccounts *taccs;
struct im_zmq *zmqstuff = NULL;
/* Connect via ZMQ */
@@ -344,10 +343,9 @@ static int run_work(const struct index_args *iargs, Stream *st,
}
}
- taccs = time_accounts_init();
-
while ( !allDone ) {
+ TimeAccounts *taccs;
struct pattern_args pargs;
int ser;
char *line;
@@ -357,6 +355,8 @@ static int run_work(const struct index_args *iargs, Stream *st,
char *ser_str = NULL;
int ok = 1;
+ taccs = time_accounts_init();
+
/* Wait until an event is ready */
time_accounts_set(taccs, TACC_EVENTWAIT);
set_last_task(sb->shared->last_task[cookie], "wait_event");
@@ -456,15 +456,19 @@ static int run_work(const struct index_args *iargs, Stream *st,
/* pargs.zmq_data will be copied into the image structure, so
* that it can be queried for "header" values etc. It will
* eventually be freed by image_free() under process_image() */
+
+ if ( sb->profile ) {
+ pthread_mutex_lock(&sb->shared->term_lock);
+ time_accounts_print_short(taccs);
+ pthread_mutex_unlock(&sb->shared->term_lock);
+ }
+ time_accounts_free(taccs);
}
im_zmq_shutdown(zmqstuff);
- time_accounts_set(taccs, TACC_FINALCLEANUP);
cleanup_indexing(iargs->ipriv);
cell_free(iargs->cell);
- if ( sb->profile ) time_accounts_print(taccs);
- time_accounts_free(taccs);
return 0;
}
diff --git a/src/time-accounts.c b/src/time-accounts.c
index 77ab9b5d..7124ed51 100644
--- a/src/time-accounts.c
+++ b/src/time-accounts.c
@@ -98,6 +98,13 @@ static int find_account(TimeAccounts *accs, enum timeaccount acc)
}
+void time_accounts_reset(TimeAccounts *accs)
+{
+ accs->n_accs = 0;
+ accs->cur_acc = TACC_NOTHING;
+}
+
+
#ifdef HAVE_CLOCK_GETTIME
void time_accounts_set(TimeAccounts *accs, enum timeaccount new_acc)
@@ -192,6 +199,49 @@ static const char *taccname(enum timeaccount acc)
}
+static const char *taccname_short(enum timeaccount acc)
+{
+ switch ( acc ) {
+ case TACC_NOTHING : return "?????";
+ case TACC_SELECT : return "selct";
+ case TACC_STREAMREAD : return "sread";
+ case TACC_SIGNALS : return "signs";
+ case TACC_QUEUETOPUP : return "qfill";
+ case TACC_STATUS : return "print";
+ case TACC_ENDCHECK : return "endch";
+ case TACC_WAKEUP : return "wakew";
+ case TACC_WAITPID : return "waitw";
+ case TACC_WAITFILE : return "wfile";
+ case TACC_HDF5OPEN : return "ofile";
+ case TACC_HDF5READ : return "rfile";
+ case TACC_FILTER : return "filtr";
+ case TACC_RESRANGE : return "rrnge";
+ case TACC_PEAKSEARCH : return "peaks";
+ case TACC_INDEXING : return "index";
+ case TACC_PREDPARAMS : return "predp";
+ case TACC_INTEGRATION : return "integ";
+ case TACC_TOTALS : return "ctotl";
+ case TACC_WRITESTREAM : return "swrte";
+ case TACC_CLEANUP : return "clean";
+ case TACC_EVENTWAIT : return "wevnt";
+ case TACC_FINALCLEANUP : return "final";
+ default : return "unkwn";
+ }
+}
+
+
+void time_accounts_print_short(TimeAccounts *accs)
+{
+ int i;
+ for ( i=0; i<accs->n_accs; i++ ) {
+ printf("%s: %.3f ", taccname_short(accs->accs[i]),
+ (double)accs->sec[i] + accs->nsec[i]/1e9);
+ }
+ printf("\n");
+ fflush(stdout);
+}
+
+
void time_accounts_print(TimeAccounts *accs)
{
int i;
diff --git a/src/time-accounts.h b/src/time-accounts.h
index 41990e7f..c7e54d0f 100644
--- a/src/time-accounts.h
+++ b/src/time-accounts.h
@@ -67,6 +67,9 @@ extern void time_accounts_free(TimeAccounts *accs);
extern void time_accounts_set(TimeAccounts *accs, enum timeaccount new_acc);
+extern void time_accounts_reset(TimeAccounts *accs);
+
+extern void time_accounts_print_short(TimeAccounts *accs);
extern void time_accounts_print(TimeAccounts *accs);
#endif /* TIME_ACCOUNTS_H */