我的输出如下:
Timestamp:1509383899190 Value:20171030224102
hbase Timestamp 2017/10/30 22:48:19
Value: 2017/10/30 22:41:02
Difference of Timestamp in Seconds:437000
Timestamp:1509383804969 Value:20171030224052
hbase Timestamp 2017/10/30 22:46:44
Value: 2017/10/30 22:40:52
Difference of Timestamp in Seconds:352000
Timestamp:1509383709215 Value:20171030224042
hbase Timestamp 2017/10/30 22:45:09
Value: 2017/10/30 22:40:42
Difference of Timestamp in Seconds:267000
Timestamp:1509383617707 Value:20171030224032
hbase Timestamp 2017/10/30 22:43:37
Value: 2017/10/30 22:40:32
Difference of Timestamp in Seconds:185000
Timestamp:1509383523756 Value:20171030224021
hbase Timestamp 2017/10/30 22:42:03
Value: 2017/10/30 22:40:21
Difference of Timestamp in Seconds:102000
当找到 Hbase Timestamp 时,我们说处理了一个请求。(上面输出中的 5)
(总开始到结束时间/请求数量)将给出平均吞吐量。
但我想编写一个java代码,它将找出每分钟处理的请求数(每分钟点击数),因为我想创建一个吞吐量图。
即使我可以通过任何工具实现这一点,那就太好了。
有人可以帮我吗?
最佳答案
正如其中一条评论中提到的,最好找到一个用于此类操作的工具,但是,自己制作一个非常简单的版本并不那么复杂,但您需要考虑一些问题,例如漂移以使其准确。
public static void main (String[] args) {
ThroughputService t = new ThroughputService();
CountDownLatch latch = new CountDownLatch(1);
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
service.scheduleAtFixedRate(t, 0, 1, TimeUnit.MINUTES);
try {
latch.await();
} catch (InterruptedException ex) {
Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
}
}
static class ThroughputService implements Runnable {
@Override
public void run() {
//code for calculating your throughput
}
}
关于java - java中每分钟的请求数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47122636/