mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-03 12:16:27 -04:00
Throttle progress printing in network stress test
This commit is contained in:
parent
e7fd9d9ed7
commit
dfaf6302b9
1 changed files with 6 additions and 0 deletions
|
@ -72,6 +72,8 @@ public class NetworkStressTest {
|
||||||
|
|
||||||
/** Number of columns in terminal (for progress reporting). */
|
/** Number of columns in terminal (for progress reporting). */
|
||||||
private int terminalColumns = 80;
|
private int terminalColumns = 80;
|
||||||
|
/** The last time a progress bar update was printed (to throttle message printing). */
|
||||||
|
private long lastProgressUpdateMillis = 0;
|
||||||
/** A directory to (temporarily) hold seed and normal nodes' configuration and state files. */
|
/** A directory to (temporarily) hold seed and normal nodes' configuration and state files. */
|
||||||
private Path testDataDir;
|
private Path testDataDir;
|
||||||
/** Whether to use localhost addresses instead of Tor hidden services. */
|
/** Whether to use localhost addresses instead of Tor hidden services. */
|
||||||
|
@ -114,6 +116,10 @@ public class NetworkStressTest {
|
||||||
private void countDownAndPrint(CountDownLatch latch, char c) {
|
private void countDownAndPrint(CountDownLatch latch, char c) {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
int remaining = (int)latch.getCount();
|
int remaining = (int)latch.getCount();
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
if (now - lastProgressUpdateMillis < 500)
|
||||||
|
return; // throttle message printing below half a second
|
||||||
|
lastProgressUpdateMillis = now;
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
String hdr = String.format("\r%s> ", this.getClass().getSimpleName());
|
String hdr = String.format("\r%s> ", this.getClass().getSimpleName());
|
||||||
String msg = (hdr.length() - 1/*carriage return*/ + remaining + 1/*final space*/ > terminalColumns)
|
String msg = (hdr.length() - 1/*carriage return*/ + remaining + 1/*final space*/ > terminalColumns)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue