问题描述
在Windows中是否存在等价的方法
''时间./a.out''
来衡量执行时间一个节目?
最好的问候,
Karthigan。
Is there an equivant method of
''time ./a.out''
in Windows to measure execution time for a program?
Best Regards,
Karthigan.
推荐答案
下载以下链接提供的软件包:
< http://unxutils.sourceforge.net/> ;
Download the package available at the following link:
<http://unxutils.sourceforge.net/>
我们不知道。好吧,这里的一些人可能碰巧知道,但是这个
不是要问的地方,因为你的问题真的不是关于C
编程语言。
尝试使用comp.os.ms-windows。*或microsoft。*新闻组之一。
-
Keith Thompson(The_Other_Keith)< ks *** @ mib.org>
诺基亚
我们必须做点什么。这是事情。因此,我们必须这样做。
- Antony Jay和Jonathan Lynn,Yes Minister
We don''t know. Well, some people here might happen to know, but this
isn''t the place to ask, since your question really isn''t about the C
programming language.
Try one of the comp.os.ms-windows.* or microsoft.* newsgroups.
--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
我把下面的C程序放在一起模糊地工作,但你可能会得到关于如何正确地做到这一点的想法。 (我以前从未在C
中使用过命令参数。)
-
Bart
#include< stdio.h>
#include< stdlib.h>
#include< time.h>
#include< string.h>
int main(int n,char ** cmds)
{char cmdstring [260] ;
int t;
int i,m;
char ** p;
if(n< = 1)
{if(n == 1)printf(" Usage:%s filename \\\
",* cmds);
return EXIT_FAILURE;
};
++ cmds; / *第一个感兴趣的参数,应该是exe名称* /
/ *必须检查所有参数组合适合cmdstring(你可以忽略这个如果
不发布你的代码!)* /
m = 0;
p = cmds;
for(i = 2; i< = n; ++ i)m + =(strlen(* p ++)+ 1);
if(m> sizeof(cmdstring))返回EXIT_FAILURE;
/ *全部麻烦系统去分隔params,现在我们需要
再次将它们加在一起,空格在* /
/ *之间提示:如果你可以使用Winmain( )相反,参数已经联合起来
* /
strcpy(cmdstring,* cmds);
for(i = 3; i< = n; ++ i)
{strcat(cmdstring,"");
strcat(cmdstring,*(+ + cmds)) ;
};
printf(" Executing%s ... \ n",cmdstring);
t = clock();
system(cmdstring);
t = clock() - t;
printf(执行时间:%d毫秒) ,t);
返回EXIT_SUCCESS;
}
I put together the C program below which vaguely works, but you might get
ideas on how to do it properly. (I''ve never used command parameters in C
before).
--
Bart
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
int main(int n,char **cmds)
{char cmdstring[260];
int t;
int i,m;
char **p;
if (n<=1)
{if (n==1) printf("Usage: %s filename\n",*cmds);
return EXIT_FAILURE;
};
++cmds; /* first param of interest, should be exe name */
/* must check all params combined fit into cmdstring (you can ignore this if
not posting your code!) */
m=0;
p=cmds;
for (i=2; i<=n; ++i) m+=(strlen(*p++)+1);
if (m>sizeof(cmdstring)) return EXIT_FAILURE;
/* All the trouble the system went to to separate the params, now we need to
join them all together again with spaces between */
/* Hint: if you can use Winmain() instead, the params are already joined up
*/
strcpy(cmdstring,*cmds);
for (i=3; i<=n; ++i)
{strcat(cmdstring," ");
strcat(cmdstring,*(++cmds));
};
printf("Executing %s ...\n",cmdstring);
t=clock();
system(cmdstring);
t=clock()-t;
printf("Execution time: %d msec",t);
return EXIT_SUCCESS;
}
这篇关于Windows中的时间./a.out等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!