简体   繁体   English

根据CPI,指令等计算程序的执行时间

[英]Calculate execution time of a program based on CPI, instructions, etc

I'm trying to calculate the execution time of an application. 我正在尝试计算应用程序的执行时间。 Assuming the only stall penalty occurs on memory access instructions (100 cycles being the penalty). 假设唯一的停顿代价发生在存储器访问指令上(100个周期为代价)。 How am I supposed to find out execution time in seconds with this info? 我应该如何用此信息找出执行时间(以秒为单位)?

CPI (CPUCycles?) = 1.0
ClockRate = 1GHZ
TotalInstructions = 59880
MemoryAccessInstructions = 8467
CacheMissRate = 62% (0.62) (5290/8467)
CacheHits = 3117
CacheMisses = 5290
CacheMissPenalty = 100 (cycles)

Assuming no other penalties. 假设没有其他惩罚。

totalCycles = TotalInstructions + CacheMisses * CacheMissPenalty ? totalCycles = TotalInstructions + CacheMisses * CacheMissPenalty?

I assume that cache hits cost same as other opcodes, so those are included in TotalInstructions. 我认为缓存命中的成本与其他操作码相同,因此它们包含在TotalInstructions中。

That's then 588880 cycles, 1GHz is 1000000000 cycles per second. 那就是588880个周期,1GHz是每秒1000000000个周期。 So that code will take 0.58888ms to execute (5.8888e-7 second). 因此该代码将花费0.58888ms的时间执行(5.8888e-7秒)。

This value is of course purely theoretical estimate, as modern CPU doesn't work like that (1 instruction = 1 cycle). 这个值当然是纯粹的理论估计值,因为现代CPU不能那样工作(1条指令= 1个周期)。 If you are interested in real world values, just profile it. 如果您对现实世界的价值感兴趣,只需对其进行概要分析。

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

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