cpu.cpp
来自「运用分布式并行计算进行AES加解密的代码~~具有一定的参考价值~~内容可以灵活修」· C++ 代码 · 共 36 行
CPP
36 行
#include "CPU.h"
#include <tchar.h>
#include "stdafx.h"
// The CTimer class was written by Feng Yuan, and was used from his post on www.codeguru.com.
inline unsigned __int64 GetCycleCount(void)
{
_asm _emit 0x0F
_asm _emit 0x31
}
CTimer::CTimer(void)
{
m_overhead = 0;
Start();
m_overhead = Stop();
}
void CTimer::Start(void)
{
m_startcycle = GetCycleCount();
}
unsigned __int64 CTimer::Stop(void)
{
return GetCycleCount()-m_startcycle-m_overhead;
}
int CTimer::Cpu()
{
CTimer timer;
TCHAR mess[30];
int cpuspeed;
timer.Start();
Sleep(1000);
int cpuspeed10 = (int)(timer.Stop()/100000);
cpuspeed = cpuspeed10 / 10;
return cpuspeed;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?