java如何计算吞吐量_如何计算进程调度算法的吞吐量(How to calculate throughput of a process scheduling algorithm)...

如何计算进程调度算法的吞吐量(How to calculate throughput of a process scheduling algorithm)

我正在尝试使用Java计算FCFS算法的吞吐量,但它总是给我零。 我做得对吗?

startTime = System.nanoTime();

total = FCFC(copyBurstTime, copyArrivalTime);

estimatedTime = System.nanoTime() - startTime;

throughput = (float)(5 / estimatedTime);

其中FCFS返回两个int值total avg。 等待时间和总平均值 周转时间,5是进程数。 吞吐量变量的类型为float。 说估计时间= 6844

I'm trying to calculate throughput of FCFS algorithm using Java, however it always gives me zero. Am I doing it right?

startTime = System.nanoTime();

total = FCFC(copyBurstTime, copyArrivalTime);

estimatedTime = System.nanoTime() - startTime;

throughput = (float)(5 / estimatedTime);

where FCFS returns two int values total avg. waiting time and total avg. turnaround time, and 5 is the number of processes. throughput variable is of type float. Say estimatedTime = 6844

原文:https://stackoverflow.com/questions/41275653

更新时间:2020-02-14 01:05

最满意答案

这是由Integer部门引起的。

试试这个

long startTime = System.nanoTime();

long estimatedTime = startTime + 1000;

float throughput = (float) (5.0 / estimatedTime);

System.out.println(throughput);

this is caused by Integer division.

try this instead

long startTime = System.nanoTime();

long estimatedTime = startTime + 1000;

float throughput = (float) (5.0 / estimatedTime);

System.out.println(throughput);

2016-12-22

相关问答

查看此链接http://www.ehow.com/how_5070951_calculate-throughput.html 。 我认为它回答了你问题的一半 check this link http://www.ehow.com/how_5070951_calculate-throughput.html. i think it answers half of your question

简而言之(粗略估计): Total throughput [mb/sec] = total MBytes processed / test exec time

所以~2.5GB在你的情况下。 或者,为了获得更准确的结果,找出群集中可用地图槽的数量(来自纱线控制台的VC总数 ),并尝试以下方法: Total throughput mb/sec = min(nrFiles, VCores total - 1) * Throughput mb/sec

但我建议使用稍微不同的设置重复该测试,因为非常高

...

如果程序将数据写入磁盘,则会发生很多不同的事情: 首先将数据写入RAM缓冲区,然后在将数据传输到下一阶段之前,以写入程序方式确认操作。 然后将数据写入Harddisk控制器,该控制器可以进行自己的缓存。 然后将数据写入硬盘驱动器,硬盘驱动器又可以进行自己的缓存。 使用高级软件测量实际吞吐量非常复杂。 一种可能性:写一个非常大的文件,预计会比操作系统/控制器/硬盘驱动器中的任何一个托架大得多。 这可以很好地估计持续写入率 。 If a program writes data to disk, the

...

至于你关于“资源使用的替代方法”的问题: 最常用于解决这类问题的模式是对象池模式 最广为人知的例子可能是ThreadPool 我建议你用int GetResource(ResourceType type, int durationInSeconds)方法实现一个ResourcePool类。 返回值指示给定ResourceType的下一个资源何时可用 As for your question regarding "alternatives to resource usage": The patter

...

我有关于iperf如何工作的类似问题。 请参阅以下文章,我在那里做了一些研究并给出了概述。 iperf如何计算网络统计信息 通常,在iperf中,它将时间戳和序列号嵌入发送方的有效负载中。 当接收者收到数据包时,它会提取这些内容并计算统计数据。 你可以在帖子中找到更多细节。 This is the closest thing I've found http://openmaniak.com/iperf.php

throughput[t] = numberOfTests[t] / overallTime[t]分别为每个线程t ,然后计算所有throughput的平均值? 然后,您还可以计算范围和标准偏差等信息,以获得更好的图像。 就我个人而言,我非常喜欢盒子情节 。 但只是数字本身会很有趣。 How about throughput[t] = numberOfTests[t] / overallTime[t] separately for each thread t, and then calculate

...

您创建了一个表格: 散列键:它是主索引,它定义表的分区。 全局索引:仅在您希望按此索引搜索时才有用,除了哈希之外。 这意味着大量的资源消耗。 我认为您只想通过哈希或仅通过全局索引进行查询。 它是否正确? 你真的想要全球指数吗? 您是想通过哈希还是哈希+范围进行查询? Turns out that I was not calculating the required throughput correctly: it's not just based on the number of written

...

这是由Integer部门引起的。 试试这个 long startTime = System.nanoTime();

long estimatedTime = startTime + 1000;

float throughput = (float) (5.0 / estimatedTime);

System.out.println(throughput);

this is caused by Integer division. try this instead

...

好吧,你想在开始时启动一个计时器,并在所有线程完成时停止它。 这给你经过的时间=结束时间 - 开始时间。 事务= 10个线程* 1000次迭代= 10000. TPS = 10000 /经过时间。 执行此类计时的最简单方法是使用CyclicBarrier。 这是一个使用带有CyclicBarrier作为计时器的屏障动作的好写法(参见上一个例子): http://tech.puredanger.com/2007/11/11/thread-coord/ 我最后的警告是,像这样的基准测试充满了危险。 一

...

只需自下而上。 常规以太网帧(没有巨型帧,没有vlan标记)总共1542 bytes ,并且可以具有1500 bytes的有效载荷。 没有选项的Ipv4头是20 bytes ,没有选项的TCP头也是20 bytes 。 因此,最终得到1542 byte链路层帧的1460 bytes可能的有效负载。 因此您的效率为1460/1542=0.9468223086900129 ,最大吞吐量为3.7872892347600517Mbps 。 但请注意,这通常会更低。 这是在建立TCP会话之后以及您是该链接的

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值