在windws下模拟使用time命令
Linux 下的 time 命令可以获取命令执行时间,Windows 下并没有类似的命令,我们可以自力更生写一个批处理,命名为time.bat。
[plain]
@echo off
set /a StartMS=%time:~3,1%*60000 + %time:~4,1%*6000 + %time:~6,1%*1000 + %time:~7,1%*100 + %time:~9,1%*10 + %time:~10,1%
%1 %2 %3 %4 %5 %6
set /a EndMS =%time:~3,1%*60000 + %time:~4,1%*6000 + %time:~6,1%*1000 + %time:~7,1%*100 + %time:~9,1%*10 + %time:~10,1%
set /a realtime = %EndMS%-%StartMS%
echo %realtime%ms
这是执行的例子,测试PHP 5.3、5.4、5.5 不同版本的运行速度:
[plain]
F:BAK>time.bat F:BAKphp-5.3.27php.exe primes.benchmark.php
PHP version 5.3.27
Found 148933 prime numbers.
867ms
F:BAK>time.bat F:BAKphp-5.4.19php.exe primes.benchmark.php
PHP version 5.4.19
Found 148933 prime numbers.
759ms
F:BAK>time.bat F:BAKphp-5.5.4php.exe primes.benchmark.php
PHP version 5.5.4
Found 148933 prime numbers.
733ms