mdbx-test: rework progess inticator.

Change-Id: Iaf3f7823ab7a0fe9f00607eb803390669c37005f
This commit is contained in:
Leonid Yuriev
2019-10-02 01:17:09 +03:00
parent 315e58578d
commit 632e688202
10 changed files with 197 additions and 36 deletions

View File

@@ -241,6 +241,56 @@ void local_suffix::pop() {
local_suffix::~local_suffix() { suffix.erase(trim_pos); }
void progress_canary(bool active) {
static chrono::time progress_timestamp;
chrono::time now = chrono::now_motonic();
if (now.fixedpoint - progress_timestamp.fixedpoint <
chrono::from_ms(42).fixedpoint)
return;
if (osal_progress_push(active)) {
progress_timestamp = now;
return;
}
if (progress_timestamp.fixedpoint == 0) {
putc('>', stderr);
progress_timestamp = now;
} else if (global::config::console_mode) {
if (active) {
static int last_point = -1;
int point = (now.fixedpoint >> 29) & 3;
if (point != last_point) {
progress_timestamp = now;
fprintf(stderr, "%c\b", "-\\|/"[last_point = point]);
}
} else if (now.fixedpoint - progress_timestamp.fixedpoint >
chrono::from_seconds(2).fixedpoint) {
progress_timestamp = now;
fprintf(stderr, "%c\b", "@*"[now.utc & 1]);
}
} else {
static int count;
if (active && now.fixedpoint - progress_timestamp.fixedpoint >
chrono::from_seconds(1).fixedpoint) {
putc('.', stderr);
progress_timestamp = now;
++count;
} else if (now.fixedpoint - progress_timestamp.fixedpoint >
chrono::from_seconds(5).fixedpoint) {
putc("@*"[now.utc & 1], stderr);
progress_timestamp = now;
++count;
}
if (count == 60) {
count = 0;
putc('\n', stderr);
}
}
fflush(stderr);
}
} // namespace logging
void log_extra(const char *msg, ...) {