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

andy2001p 2003-09-22 09:17:08
怎么样写一个程序,通过递归方法创建进程1000次来测定Windows2000中进程创建速度.写一个程序,通过递归方法创建线程1000次来测定Windows2000中线程创建速度.
...全文
191 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
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;
}

70,020

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧