博客日历
2024年05月 | ||||||
一 | 二 | 三 | 四 | 五 | 六 | 七 |
29 | 30 | 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 1 | 2 |
存档
2024年03月 04月 2021年
01月 02月 11月 12月 2020年
02月 03月 04月 05月 06月 07月
09月 2018年
09月 2017年
01月 02月 07月 2016年
01月 04月 07月 08月 11月 12月
2015年
01月 02月 03月 05月 09月 10月
11月 2014年
01月 02月 03月 04月 05月 06月
07月 08月 09月 10月 11月 12月
2013年
01月 02月 03月 04月 05月 06月
07月 08月 09月 10月 11月 12月
2012年
01月 02月 03月 04月 05月 06月
07月 08月 09月 10月 11月 12月
2011年
01月 02月 03月 04月 05月 06月
07月 08月 09月 10月 11月 12月
2010年
01月 02月 03月 04月 05月 06月
07月 08月 09月 10月 11月 12月
2009年
03月 04月 05月 06月 07月 08月
09月 10月 11月 12月
QueryPerformanceFrequency,RDTSC,CPU频率
//warning C4035: 'RDTSC' : no return value
#pragma warning(disable:4035)
#include <Windows.h>
//RDTSC-Read Time-Stamp Counter
//自开机以来CPU经历的时钟周期数
unsigned __int64 RDTSC()
{
__asm _emit 0x0F;
__asm _emit 0x31;
}
//CPU的频率
double CpuFrequency()
{
//On a multiprocessor machine, it should not matter which processor is called.
//However, you can get different results on different processors due to bugs in
//the BIOS or the HAL. To specify processor affinity for a thread, use the SetThreadAffinityMask function.
HANDLE hThread=GetCurrentThread();
SetThreadAffinityMask(hThread,0x1);
//主板上高精度定时器的晶振频率
//这个定时器应该就是一片8253或者8254
//在intel ich7中集成了8254
LARGE_INTEGER lFrequency;
QueryPerformanceFrequency(&lFrequency);
//printf("高精度定时器的晶振频率:%1.0fHz.\n",(double)lFrequency.QuadPart);
//这个定时器每经过一个时钟周期,其计数器会+1
LARGE_INTEGER lPerformanceCount_Start;
QueryPerformanceCounter(&lPerformanceCount_Start);
//RDTSC指令:获取CPU经历的时钟周期数
__int64 _i64StartCpuCounter=RDTSC();
//延时长一点,误差会小一点
//int nTemp=100000;
//while (--nTemp);
Sleep(200);
LARGE_INTEGER lPerformanceCount_End;
QueryPerformanceCounter(&lPerformanceCount_End);
__int64 _i64EndCpuCounter=RDTSC();
//f=1/T => f=计数次数/(计数次数*T)
//这里的“计数次数*T”就是时间差
double fTime=((double)lPerformanceCount_End.QuadPart-(double)lPerformanceCount_Start.QuadPart)
/(double)lFrequency.QuadPart;
return (_i64EndCpuCounter-_i64StartCpuCounter)/fTime;
}
int main(int argc, char* argv[])
{
printf("CPU频率为:%1.6fMHz.\n",CpuFrequency()/1000000.0);
return 0;
}
分类:Win32/C++ 查看次数:10945 发布时间:2010/4/23 16:35:45
Tomcat主目录的正确配置
<Host name="localhost" appBase=""
unpackWARs="true" autoDeploy="true"
xmlValidation="false"
xmlNamespaceAware="false">
<Context path=""
docBase="/03.Webs/WebRoot" reloadable="true"></Context>
注意appBase和docBase的不同:
appBase目录下的每个子目录都会被当做一个应用程序,具有独立的session等。
docBase是一个独立应用程序的物理路径,其目录下的所有目录都属于这个应用程序。
如果遇到无法跨目录使用session变量,或者无法include上级目录,则肯定是这里配置错了。
分类:Web开发 查看次数:3754 发布时间:2010/4/20 15:07:04