计算程序执行时间的命令行工

来源:互联网 发布:重庆科技学院选课软件 编辑:程序博客网 时间:2024/06/05 12:50

计算命令的执行时间:

找到了一个 exec15.zip 

Exec - Written by Bill Stewart (bstewart@iname.com)

Executes a program using the CreateProcess Win32 API.

Usage:  Exec [-c] [-s n] [-w [-e]] [-d dir] -- program [arguments [...]]

-c      Creates a new console (if running a console application)
-s n    Configures the initial window state (e.g. -s 1 = start normally)
-w      Waits for the program to finish
-e      Displays the program's elapsed time (hh:mm:ss)
-d dir  Configures a starting directory for the program (use quotes if needed)

Exec's command-line arguments must all appear BEFORE the program name. The --
characters tell Exec that it has no more options and to treat the remainder
of the command line as the command line it should run.

Example:

Exec -w -e -- cmd /c dir "C:/Program Files" /b /s 

 

=================

计算命令的启动时间:

Windows Server 2003 Resource Kit Tools里的 Timeit.exe !上面的 exec 只能计算“逝去时间”,而不能计算“命令执行成功所花的时间”。例如我要 exec 计算 Explorer.exe /n,D:/nirsoft“命令执行成功所花的时间”,它就无能为力了,它只能计算 explorer.exe 运行的时间,即我把 d:/nirsoft 关掉后它才会报告一个“逝去时间”。
Timeit.exe 可以计算“逝去时间”和“创建时间”

下面计算了打开 d:/nirsoft 的三种方式所用时间。

1.用 explorer.exe 打开
命令:timeit.exe Explorer.exe /n,D:/nirsoft
Process Time:     0:00:01.375

2.打开 .lnk
命令:timeit.exe %SystemRoot%/System32/Rundll32.exe Url,FileProtocolHandler "%HOMEDRIVE%%HOMEPATH%/桌面/nirsoft.lnk"
Process Time:     0:00:00.281

3.用系统关联打开
命令:timeit.exe cmd /c start d:/nirsoft
Process Time:     0:00:00.062

可以看出,用系统关联打开的时间最短!
再做个比较来证明这点:浏览器加网址参数 和 用关联打开网址

C:/>timeit.exe E:/Program Files/Opera/opera.exe http://www.cn-dos.net/forum

Version Number:   Windows NT 5.1 (Build 2600)
Exit Time:        3:55 pm, Friday, September 12 2008
Elapsed Time:     0:00:00.828
Process Time:     0:00:00.421
System Calls:     25648
Context Switches: 2844
Page Faults:      11121
Bytes Read:       187914
Bytes Written:    35690
Bytes Other:      126367

C:/>timeit.exe cmd /c start http://www.cn-dos.net/forum

Version Number:   Windows NT 5.1 (Build 2600)
Exit Time:        3:55 pm, Friday, September 12 2008
Elapsed Time:     0:00:00.421
Process Time:     0:00:00.109
System Calls:     21833
Context Switches: 2464
Page Faults:      3782
Bytes Read:       185279
Bytes Written:    31984
Bytes Other:      42080

从中可以看出,在“运行”对话框中直接输入网址,和用浏览器加网址参数是绝对不同的。浏览器加网址参数 不但速度慢,且更消耗系统资源。

原创粉丝点击