diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-01-10 14:18:51 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-01-11 08:31:25 +0100 |
commit | d4adaf8c095eadd51528fefa486ff10c907386ed (patch) | |
tree | 4220664b32f2f110d476672a259566b25f89f0ee /lib/libscan.c | |
parent | a433e04e79a096dbbb660c3a50a8317ccc052316 (diff) | |
download | barebox-d4adaf8c095eadd51528fefa486ff10c907386ed.tar.gz barebox-d4adaf8c095eadd51528fefa486ff10c907386ed.tar.xz |
ubiformat: Lower message printing frequency
During scanning and formatting printing the messages on a serial line
has significant overhead up to the point where it takes longer to print
the messages than it takes to do the work. Lower the message printing
frequency to improve performance.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/libscan.c')
-rw-r--r-- | lib/libscan.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libscan.c b/lib/libscan.c index 74a24b5011..c4139e69d1 100644 --- a/lib/libscan.c +++ b/lib/libscan.c @@ -39,6 +39,7 @@ int libscan_ubi_scan(struct mtd_info *mtd, struct ubi_scan_info **info, int eb, v = (verbose == 2), pr = (verbose == 1), eb_cnt; struct ubi_scan_info *si; unsigned long long sum = 0; + uint64_t lastprint = 0; eb_cnt = mtd_div_by_eb(mtd->size, mtd); @@ -66,8 +67,12 @@ int libscan_ubi_scan(struct mtd_info *mtd, struct ubi_scan_info **info, if (v) normsg_cont("scanning eraseblock %d", eb); if (pr) { - printf("\r" PROGRAM_NAME ": scanning eraseblock %d -- %2u %% complete ", - eb, (eb + 1) * 100 / eb_cnt); + if (is_timeout(lastprint, 300 * MSECOND) || + eb == eb_cnt - 1) { + printf("\r" PROGRAM_NAME ": scanning eraseblock %d -- %2u %% complete ", + eb, (eb + 1) * 100 / eb_cnt); + lastprint = get_time_ns(); + } } ret = mtd_peb_is_bad(mtd, eb); |