• 全部
  • 问答

怎么样写一个程序,通过递归方法创建进程1000次来测定Windows2000中进程创建速度.写一个程序,通过递归方法创建线程1000次来测定Windows200

andy2001p 2003-09-22 09:17:08
怎么样写一个程序,通过递归方法创建进程1000次来测定Windows2000中进程创建速度.写一个程序,通过递归方法创建线程1000次来测定Windows2000中线程创建速度.
...全文
134 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
fireseed 2003-09-23

first, define a Timer-class like following

// CTimer define
class CTimer
{
public:
CTimer()
{
QueryPerformanceFrequency(&m_Frequency);
Start();
}
void Start()
{
QueryPerformanceCounter(&m_StartCount);
}
double End()
{
LARGE_INTEGER CurrentCount;
QueryPerformanceCounter(¤tCount);
return double(CurrentCount.LowPart - m_StartCount.LowPart) / (double)m_Frequency.LowPart;
}
private:
LARGE_INTEGER m_Frequency;
LARGE_INTEGER m_StartCount;
};

// CTimer end define

and then.


CTimer t;
// Write a circle here, and do noting.
// so will test the expended time of null-circle
double d1 = t.end();



t.start();
// Create your process in the circle that same to previous
//----
double d2 = t.end();

subtract d1 from d2 is the pure expended time of CreateProcess.
回复
HR-TANG 2003-09-23
我对C的进程问题还不清楚!
学习!!
回复
solar 2003-09-22
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
int n;
int count;
char name[1024];
char cmd[1024];
char timestamp[64];
if((n=sscanf(lpCmdLine,"%d %s",&count,timestamp))<1)
{
MessageBox(NULL,"not enough parameter","Error",MB_OK);
return 1;
}

if(n==1)
{
FILETIME ft;
SYSTEMTIME st;
GetSystemTime(&st);
SystemTimeToFileTime(&st,&ft);
sprintf(timestamp,"%ld:%ld",(long)ft.dwHighDateTime,(long)ft.dwLowDateTime);
}
if(count==0)
{
if(n!=1)
{
long lTmp[2];
FILETIME ft;
SYSTEMTIME st[2];
sscanf(timestamp,"%ld:%ld",<mp[0],<mp[1]);
ft.dwHighDateTime = (DWORD)lTmp[0];
ft.dwLowDateTime = (DWORD)lTmp[1];
FileTimeToSystemTime(&ft,&st[0]);
GetSystemTime(&st[1]);
sprintf(cmd,"%02d:%02d.%03d to %02d:%02d.%03d",
st[0].wMinute,st[0].wSecond,st[0].wMilliseconds,
st[1].wMinute,st[1].wSecond,st[1].wMilliseconds
);
MessageBox(NULL,cmd,"Compeleted",MB_OK);
}
return 0;
}

count--;
GetModuleFileName(NULL,name,sizeof(name));
sprintf(cmd,"%s %d %s",name,count,timestamp);
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si,0,sizeof(si));
memset(&pi,0,sizeof(pi));

if(CreateProcess(name,cmd,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
{
CloseHandle(pi.hProcess);
}

return 0;
}
回复
发帖
C语言
创建于2007-09-28

6.3w+

社区成员

C语言相关问题讨论
申请成为版主
帖子事件
创建了帖子
2003-09-22 09:17
社区公告
暂无公告