diff options
| author | Dennis Camera <skonfig@dtnr.ch> | 2022-08-21 10:56:37 +0200 |
|---|---|---|
| committer | Dennis Camera <skonfig@dtnr.ch> | 2022-08-21 10:56:37 +0200 |
| commit | 32cf6255bfaa36d8e7b1f94e58a6044eba628577 (patch) | |
| tree | 66ebb508ded42264a44db70319b6d306e90ee809 /src | |
| parent | 4c1347d2285aa7b6af772731adc417c816ac6112 (diff) | |
| download | skonfig-c-32cf6255bfaa36d8e7b1f94e58a6044eba628577.tar.gz skonfig-c-32cf6255bfaa36d8e7b1f94e58a6044eba628577.zip | |
[src/run.c] Time configuration run
Diffstat (limited to 'src')
| -rw-r--r-- | src/run.c | 40 |
1 files changed, 30 insertions, 10 deletions
@@ -14,11 +14,17 @@ #include <sys/stat.h> #include <sys/types.h> #include <dirent.h> +#include <time.h> /* as per mktemp(3p) the last 6 characters of object_marker_tmpl must be Xs */ static char *object_marker_tmpl = ".skonfig-XXXXXX"; +double tv_diff(struct timespec *start, struct timespec *end) { + return (end->tv_sec + end->tv_nsec/10e9) - (start->tv_sec + start->tv_nsec/10e9); +} + + /** * sk_run_gen_workdir_path: * determine the path to use for the local workdir and create it if necessary. @@ -288,21 +294,29 @@ sk_run_error sk_run_host( const char *target_host, bool dry_run, const char *local_hostdir, struct sk_config *config) { sk_run_error rv = SK_RUN_OK; + struct timespec start, end; + const char *run_type = (!dry_run ? "configuration" : "dry"); + + (void)clock_gettime(CLOCK_MONOTONIC, &start); + + sk_info("%s: Starting %s run", target_host, run_type); /* create the local hostdir */ rv = sk_run_prepare_local_hostdir(local_hostdir); if (SK_RUN_OK != rv) return rv; - if (setenv("__global", local_hostdir, 1)) - return SK_RUN_GENERIC_ERROR; + if (setenv("__global", local_hostdir, 1)) { + rv = SK_RUN_GENERIC_ERROR; + goto ret; + } /* create conf path and link conf dirs */ rv = sk_run_link_local_hostdir(local_hostdir, config); - if (SK_RUN_OK != rv) return rv; + if (SK_RUN_OK != rv) goto ret; /* link types for type runner */ rv = sk_run_install_type_cmds(local_hostdir); - if (SK_RUN_OK != rv) return rv; + if (SK_RUN_OK != rv) goto ret; /* generate and store object marker file */ char object_marker[strlen(object_marker_tmpl)+1]; @@ -311,16 +325,25 @@ sk_run_error sk_run_host( mktemp(object_marker); if (!*object_marker) { sk_error("generating object marker failed: %s", strerror(errno)); - return SK_RUN_GENERIC_ERROR; + rv = SK_RUN_GENERIC_ERROR; + goto ret; } #else #error no available implementation to generate object marker #endif rv = sk_run_setup_object_marker_file(local_hostdir, object_marker); - if (SK_RUN_OK != rv) return rv; + if (SK_RUN_OK != rv) goto ret; - return SK_RUN_OK; + + ret: + if (SK_RUN_OK == rv) { + (void)clock_gettime(CLOCK_MONOTONIC, &end); + + sk_info("%s: Finished %s run in %.2f seconds", + target_host, run_type, tv_diff(&start, &end)); + } + return rv; } sk_run_error sk_run_start( @@ -338,9 +361,6 @@ sk_run_error sk_run_start( return (rv = SK_RUN_GENERIC_ERROR); } - sk_info("%s: Starting %s run", - target_host, (!dry_run ? "configuration" : "dry")); - /* determine local workdir */ if ((NULL == sk_run_gen_workdir_path(config, local_workdir))) { return SK_RUN_GENERIC_ERROR; |
