As I’ve said in my previous post, I’ve written a script to work with text files and measured its execution time. Time of execution is very relative, but it is good enough to compare two tools on the same computer. So how to measure the script execution time? Maybe getting your stopwatch and trying to figure out when program starts and when it finis its work is not the best idea.
Using Windows, we can utilize Microsoft PowerShell. It is installed by default in Windows 7 and 8 (and on the servers). I’m not sure if it is on the Windows XP and Vista, but you can quickly download and install it while it’s not a part of the system.
So in PowerShell there is a Measure-Command commandlet, that can count how many time do the tool needs to execute. You can just type:
Measure-command {command}
And it gives you the results. So I’ve typed all the needed to run my tool:
Measure-Command {Get-Content .\bigfile.txt | cscript //nologo .\myTool.js > output.txt }
And after a while it returned mi this data:
Days : 0 Hours : 0 Minutes : 2 Seconds : 15 Milliseconds : 507 Ticks : 1355078301 TotalDays : 0,00156837766319444 TotalHours : 0,0376410639166667 TotalMinutes : 2,258463835 TotalSeconds : 135,5078301 TotalMilliseconds : 135507,8301
Anyway, if you haven’t any experience with Windows PowerShell, you cannot just redirect input stream to your command. You must use another commandlet called Get-Content and make a pipe to your command.
No comments:
Post a Comment