简体   繁体   English

计算吞吐量

[英]Calculate Throughput

I have a the following scenarios. 我有以下场景。 I am trying to calculate throughput of the java's XSLT transformer. 我正在尝试计算java的XSLT转换器的吞吐量。 I have 10 threrads, each iterates 1000 times. 我有10个threrads,每次迭代1000次。 The task of the thread is to read the XML and XSLT file and trasnform it and write to a new file. 该线程的任务是读取XML和XSLT文件并对其进行转换并写入新文件。

I want to calculate the TPS. 我想计算TPS。 Can you please suggest the way to calculate TPS? 你能建议一下计算TPS的方法吗?

Thanks and Regards, 感谢致敬,

Srinivas. SRINIVAS。

Well, you want to start a timer at the beginning and stop it when all threads complete. 好吧,你想在开始时启动一个计时器,并在所有线程完成时停止它。 That gives you elapsed time = end time - begin time. 这给你经过的时间=结束时间 - 开始时间。 Transactions = 10 threads * 1000 iterations = 10000. TPS = 10000 / elapsed time. 事务= 10个线程* 1000个迭代= 10000.TPS = 10000 /经过时间。

The easiest way to do this kind of timing is with a CyclicBarrier. 使用CyclicBarrier进行此类计时的最简单方法。 Here's a good writeup of using a barrier action with a CyclicBarrier as a timer (see last example): 这是一个很好的写作,使用一个带有CyclicBarrier作为计时器的屏障动作(参见最后一个例子):

My final caveat would be that benchmarking something like this is fraught with peril. 我最后的警告是,像这样的基准测试充满了危险。 Some suggestions: 一些建议:

  • Run more than 1000 iterations. 运行超过1000次迭代。 You need to let hotspot warm up. 你需要让热点热身。 Preferably you should let the test run at least 10 minutes. 最好让测试运行至少10分钟。
  • Don't discount GC times. 不要打折GC时间。 You need to be aware of what GC you're using and how its pause times are affecting your results. 您需要了解您正在使用的GC以及其暂停时间对结果的影响。 Running with -verbose:gc at least a few times is extremely valuable. 使用-verbose:gc至少运行几次非常有价值。 See here for more: http://java.sun.com/developer/technicalArticles/Programming/GCPortal/ 有关更多信息,请参阅此处: http//java.sun.com/developer/technicalArticles/Programming/GCPortal/
  • Run multiple repetitions in the same process until you see repeatable results. 在同一过程中运行多次重复,直到您看到可重复的结果。
  • Do many runs until you believe the numbers are consistent. 做多次运行直到您认为数字是一致的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM