Is there a built-in way to measure execution time of a command on the Windows command line?
相关问题
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
- I want to trace logs using a Macro multi parameter
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- CosmosDB emulator can't start since port is al
- How to print to stdout from Python script with .py
If you want
Try copying the following script into a new batch file (e.g. timecmd.bat):
Usage
If you put timecmd.bat in a directory in your path, you can call it from anywhere like this:
E.g.
If you want to do output redirection, you can quote the command like this:
This should handle commands that run from before- to after-midnight, but the output will be wrong if your command runs for 24 hours or more.
The one-liner I use in Windows Server 2008 R2 is:
So long as mycommand doesn't require quotes (which screws with cmd's quote processing). The
/v:on
is to allow for the two different TIME values to be evaluated independently rather than once at the execution of the command."Lean and Mean" TIMER with Regional format, 24h and mixed input support
Adapting Aacini's substitution method body, no IF's, just one FOR (my regional fix)
1: File timer.bat placed somewhere in %PATH% or the current dir
Usage:
timer & echo start_cmds & timeout /t 3 & echo end_cmds & timer
timer & timer "23:23:23,00"
timer "23:23:23,00" & timer
timer "13.23.23,00" & timer "03:03:03.00"
timer & timer "0:00:00.00" no & cmd /v:on /c echo until midnight=!timer_end!
Input can now be mixed, for those unlikely, but possible time format changes during execution
2: Function :timer bundled with the batch script (sample usage below):
:: to test it, copy-paste both above and below code sections
CE,DE and CS,DS stand for colon end, dot end and colon set, dot set - used for mixed format support
There's also TimeMem (March 2012):
Just a little expansion of the answer from Casey.K about using the
Measure-Command
from PowerShell:You can invoke PowerShell from the standard command prompt, like this:
This will eat the standard output, but you can prevent that by adding
| Out-Default
like this from PowerShell:Or from a command prompt:
Of course, you're free to wrap this in a script file
*.ps1
or*.bat
.