[英]Measuring the CPU frequency scaling effect
Recently I am trying to measure the effect of the cpu scaling. 最近,我正在尝试测量cpu缩放的效果。 Is it accurate if I use this clock to measure it? 如果我用这个时钟来测量它准确吗?
template<std::intmax_t clock_freq>
struct rdtsc_clock {
typedef unsigned long long rep;
typedef std::ratio<1, clock_freq> period;
typedef std::chrono::duration<rep, period> duration;
typedef std::chrono::time_point<rdtsc_clock> time_point;
static const bool is_steady = true;
static time_point now() noexcept
{
unsigned lo, hi;
asm volatile("rdtsc" : "=a" (lo), "=d" (hi));
return time_point(duration(static_cast<rep>(hi) << 32 | lo));
}
};
Update : 更新 :
According to the comment from my another post , I believe redtsc cannot use for measure the effect of cpu frequency scaling because the counter from the redtsc does not affected by the CPU frequency, am i right? 根据我另一篇文章的评论,我相信redtsc不能用于衡量cpu频率缩放的效果,因为redtsc的计数器不受CPU频率的影响,对吗?
简而言之,根据我另一篇文章中的评论,redtsc无法用于衡量cpu频率缩放的效果,因为redtsc的计数器不受CPU频率的影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.