org.bdware.dogp.sample.RecvCounter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doip-audit-tool Show documentation
Show all versions of doip-audit-tool Show documentation
doip audit tool developed by bdware
package org.bdware.dogp.sample;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.concurrent.atomic.AtomicInteger;
public class RecvCounter extends Thread {
static Logger LOGGER = LogManager.getLogger(RecvCounter.class);
AtomicInteger i;
String tag;
public RecvCounter(String tag) {
this.tag = tag;
i = new AtomicInteger(0);
}
@Override
public void run() {
for (; ; ) {
long pre = System.currentTimeMillis();
int preCount = i.get();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
LOGGER.info(tag + " RECV:" + i.get() + " deltaTPS:" + (i.get() - preCount) * 1000 / (System.currentTimeMillis() - pre));
}
}
public void inc() {
i.incrementAndGet();
}
}