吞吐量测量
我编写了一个简单的负载测试工具来测试Java模块的性能。我面临的一个问题是吞吐量测量算法。测试在多个线程中执行(客户端配置测试应重复多少次),并记录执行时间。因此,当测试完成时,我们有以下历史记录:
4 test executions
2 threads
36ms overall time
- idle
* test execution
5ms 9ms 4ms 13ms
T1 |-*****-*********-****-*************-|
3ms 6ms 7ms 11ms
T2 |-***-******-*******-***********-----|
<-----------------36ms--------------->
目前,我通过以下方式计算吞吐量(每秒):1000/overallTime * threadCount
。
但有问题。如果一个线程将更快地完成它自己的测试(无论出于何种原因),该怎么办:
3ms 3ms 3ms 3ms
T1 |-***-***-***-***----------------|
3ms 6ms 7ms 11ms
T2 |-***-******-*******-***********-|
<--------------32ms-------------->
在这种情况下,实际吞吐量要好得多,因为测量的吞吐量受以下限制: 最慢的线程。所以,我的问题是如何测量多线程环境中代码执行的吞吐量。
I wrote simple load testing tool for testing performance of Java modules. One problem I faced is algorithm of throughput measurements. Tests are executed in several thread (client configure how much times test should be repeated), and execution time is logged. So, when tests are finished we have following history:
4 test executions
2 threads
36ms overall time
- idle
* test execution
5ms 9ms 4ms 13ms
T1 |-*****-*********-****-*************-|
3ms 6ms 7ms 11ms
T2 |-***-******-*******-***********-----|
<-----------------36ms--------------->
For the moment I calculate throughput (per second) in a following way: 1000 / overallTime * threadCount
.
But there is problem. What if one thread will complete it's own tests more quickly (for whatever reason):
3ms 3ms 3ms 3ms
T1 |-***-***-***-***----------------|
3ms 6ms 7ms 11ms
T2 |-***-******-*******-***********-|
<--------------32ms-------------->
In this case actual throughput is much better because of measured throughput is bounded by
the most slow thread. So, my question is how should I measure throughput of code execution in multithreaded environment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
分别为每个线程
t
分别计算throughput[t] = numberOfTests[t]/overallTime[t]
,然后计算所有吞吐量
的平均值怎么样? >?然后,您还可以计算范围和标准差等内容,以获得更好的图像。就我个人而言,我非常喜欢箱线图。但仅仅数字本身就很有趣。
How about
throughput[t] = numberOfTests[t] / overallTime[t]
separately for each threadt
, and then calculate the mean of allthroughput
?Then you can also calculate things like range and standard deviation to get a better picture. Personally I'm very fond of box plots. But just the numbers themselves would be interesting.
我知道有点晚了,但我有两篇与您的问题相关的博客文章。第一个描述了如何测量吞吐量(以及响应时间)。第二个描述了一种绘制吞吐量图的方法。
I know its a bit late, but I have two blog posts associated with your question. The first describes how you measure throughput (and response time). The second describes a way to graph throughput.