From 373bf7749fd7feceeda4f19e9db91317373d5f2d Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 24 Jan 2015 15:07:23 +1100 Subject: [PATCH] ckdb - report reload total lines per second --- src/ckdb.c | 13 ++++++++++--- src/ckdb.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 1158e248..770a8c5a 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -2995,7 +2995,8 @@ static bool reload_from(tv_t *start) bool finished = false, matched = false, ret = true, ok, apipe = false; char *filename = NULL; uint64_t count, total; - tv_t now; + tv_t now, begin; + double diff; FILE *fp = NULL; reload_buf = malloc(MAX_READ); @@ -3016,6 +3017,7 @@ static bool reload_from(tv_t *start) quithere(1, "Failed to open '%s'", filename); setnow(&now); + copy_tv(&begin, &now); tvs_to_buf(&now, run, sizeof(run)); snprintf(reload_buf, MAX_READ, "reload.%s.s0", run); LOGQUE(reload_buf); @@ -3099,12 +3101,17 @@ static bool reload_from(tv_t *start) PQfinish(conn); + setnow(&now); + diff = tvdiff(&now, &begin); + if (diff == 0) + diff = 1; + snprintf(reload_buf, MAX_READ, "reload.%s.%"PRIu64, run, total); LOGQUE(reload_buf); - LOGWARNING("%s(): read %d file%s, total %"PRIu64" line%s", + LOGWARNING("%s(): read %d file%s, total %"PRIu64" line%s %.2f/s", __func__, processing, processing == 1 ? "" : "s", - total, total == 1 ? "" : "s"); + total, total == 1 ? "" : "s", (total / diff)); if (everyone_die) return true; diff --git a/src/ckdb.h b/src/ckdb.h index f50ea45d..dd85c418 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -52,7 +52,7 @@ #define DB_VLOCK "1" #define DB_VERSION "0.9.6" -#define CKDB_VERSION DB_VERSION"-0.900" +#define CKDB_VERSION DB_VERSION"-0.901" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__