VS2005中如何使用QueryPerformanceFrequency()
来源:互联网 发布:ads软件下载 编辑:程序博客网 时间:2024/04/27 20:58
VS2005中如何使用QueryPerformanceFrequency()
// f(x) = x which f(x) returns the numbers of 1 for all the numbers from 1 to x. For example: // f(1) = 1, f(2) = 1, and f(10) = 2, f(11) = 4 #include "stdafx.h" using namespace std; #define BASE_DECIMAL 10 /* Define the factor of division */ /* This function used to get the numbers of 1 for a give number */ inline int GetNumbersOfOne(int n) int _tmain(int argc, _TCHAR* argv[]) LARGE_INTEGER startCount; QueryPerformanceFrequency(&freq); elapsed = (double)(endCount.QuadPart - startCount.QuadPart) / freq.QuadPart; return 0;
VS2005中如何使用QueryPerformanceFrequency() // GetNumbersOfOne.cpp : Defines the entry point for the console application.
// This program used to get the numbers from 0-1234567890 which satisfy following rule:
#include <iostream>
#include <crtdbg.h>
#include <sys/timeb.h>
#include <time.h>
#include <windows.h>
#define LEFT_DECIMAL 1 /* Define the number we will count */
#define MAX_NUMBER 1234567890 /* Define the max number to check */
{
int count = 0;
do {
count += ((n % BASE_DECIMAL) == LEFT_DECIMAL);
} while ((n /= BASE_DECIMAL) > 0);
return count;
}
{
int i = 0;
int count = 0;
LARGE_INTEGER endCount;
LARGE_INTEGER freq;
QueryPerformanceCounter(&startCount);
while (++ i < MAX_NUMBER) {
count += GetNumbersOfOne(i);
if (count == i) {
cout << i << "/t" << count << endl;
}
}
QueryPerformanceCounter(&endCount);
double elapsed;
cout << "Total time elapsed : " << elapsed << endl;
}
- VS2005中如何使用QueryPerformanceFrequency()
- Vs2005中Session 如何使用
- VS2005中如何使用log4Net
- 如何在vs2005中使用.NET 3.0
- 如何在VS2005中使用GDI+
- 如何在VS2005中使用PC-Lint
- 如何在VS2005中使用GDI+
- 如何在VS2005中使用GDI+
- vs2005如何使用
- QueryPerformanceFrequency
- QueryPerformanceFrequency
- QueryPerformanceFrequency
- QueryPerformanceFrequency
- QueryPerformanceFrequency
- QueryPerformanceFrequency
- QueryPerformanceFrequency()
- 使用QueryPerformanceFrequency 计算程序执行时间
- 使用QueryPerformanceFrequency、QueryPerformanceCounter精确计时
- C# SerialPort 读写三菱FX系列PLC
- 使用Internet连接共享使局域网连接到Internet
- 软件生存周期模型总结
- 64位Linux上安装Memcached详细步骤
- 使用SyGate代理服务器使局域网连接到Internet
- VS2005中如何使用QueryPerformanceFrequency()
- 使用WinGate代理服务器使局域网连接到Internet
- 讨论:Java编程风格的改变
- Desktop Java
- 解决soap问题
- 制作不同用途的双绞线网线
- 组建一个小的局域网
- 安装Windows2000 Server
- 安装工作站