测量进程消耗的CPU时钟 [英] Measuring CPU clocks consumed by a process

查看:109
本文介绍了测量进程消耗的CPU时钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用C编写了一个程序.它是根据研究创建的程序.我想计算程序消耗的确切CPU周期.确切的循环数. 知道如何找到它吗?

I have written a program in C. Its a program created as result of a research. I want to compute exact CPU cycles which program consumes. Exact number of cycles. Any idea how can I find that?

推荐答案

valgrind工具cachegrind(valgrind --tool=cachegrind)将为您提供详细的输出,包括执行的指令数,高速缓存未命中和分支预测未命中.这些可以归结为汇编程序的各个行,因此原则上(了解您的确切体系结构)您可以从此输出中得出精确的周期数.

The valgrind tool cachegrind (valgrind --tool=cachegrind) will give you a detailed output including the number of instructions executed, cache misses and branch prediction misses. These can be accounted down to individual lines of assembler, so in principle (with knowledge of your exact architecture) you could derive precise cycle counts from this output.

由于缓存的影响,它会因执行而改变.

Know that it will change from execution to execution, due to cache effects.

cachegrind工具的文档位于此处.

这篇关于测量进程消耗的CPU时钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆