我想使用Lmax Disruptor进行性能测试:
这样我可以干净地测量缓冲区变空的速度。如果我"混合"添加许多消息(引入一些延迟)和处理我可能对处理速度的确定结果不太确定。
但我似乎没有找到"暂停"在LMAX Disruptor(https://lmax-exchange.github.io/disruptor/docs/com/lmax/disruptor/dsl/Disruptor.html)中可用,有没有办法制作一个?
答案 0 :(得分:1)
答案在很大程度上取决于你打扰破坏者的意思。
您可以轻松拥有一个消费者,它不会释放环形缓冲区中的插槽,直到它到达 @Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
//Checking if the item is in checked state or not, if not make it in checked state
if (menuItem.isChecked()) menuItem.setChecked(false);
else menuItem.setChecked(true);
//Closing drawer on item click
drawerLayout.closeDrawers();
//Check to see which item was being clicked and perform appropriate action
switch (menuItem.getItemId()) {
case R.id.first:
toolbar.setTitle("First Item");
return true;
case R.id.second:
toolbar.setTitle("Second Item");
return true;
}
}
消息。然而,耗尽环形缓冲区所花费的时间完全取决于消费者的速度。
然而,如果你想要对破坏者的成本进行基准测试,那就是一个更为复杂的命题。我开始研究破坏者项目自己的性能测试。
在突发性工作负载中,破坏者的批处理效果实际上可以通过摊销昂贵的操作(例如网络或磁盘IO)的成本来提高。