使用 SPIM 测量执行时间
我需要测量用汇编语言编写的河内塔程序的执行时间。是否有任何函数或特定寄存器值用于执行此任务..?
I need to measure execution time of Hanoi Towers program, written in assembly language. Is there any function or specific register value used to do this task..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太了解 SPIM,但任何 mips 处理器都有一个计数寄存器,它以 CPU 时钟的一半递增。如果 SPIM 模拟该寄存器,您可以轻松测量程序执行时间。只需在程序执行之前和之后读取其内容即可。
如果 SPIM 不模拟该寄存器或对指令进行计数,则 MARS mips 模拟器会模拟该寄存器或计数指令。一般来说,在模拟器中测量时间是没有意义的,因为根据主机硬件的不同,同一程序的时间会有所不同。指令计数器是更好的性能衡量标准,因为它与仿真器主机无关。
MARS 有一个指令计数器,我认为它可以运行 SPIM 程序。
经过短暂的搜索,我发现了这个:
http://www.cs.colostate.edu/~mstrout/spim/keepstats .html
修改了对指令进行计数的 SPIM。
I don't know specifically about SPIM but any mips processor has a Count register which increments at half CPU clock. If SPIM emulates this register you can easy measure program execution time. Just read its content before and after program was executed.
If SPIM does not emulate this register or counts instructions, MARS mips emulator does. In general measuring time in emulator is pointless since depending on the host hardware time would be different for the same program. Instruction counter is a better measure of performance since it would be the same independent of emulator host.
MARS has an instruction counter and I think it would run SPIM program.
After a short search I found this:
http://www.cs.colostate.edu/~mstrout/spim/keepstats.html
Modified SPIM that counts instructions.