站长资源操作系统
在windws下模拟Linux下可获取命令执行时间的time命令
简介Linux 下的 time 命令可以获取命令执行时间,Windows 下并没有类似的命令,我们可以自力更生写一个批处理,命名为time.bat。 [plain] @echo off set /a StartMS=%time:~3,1%*60000 + %time:~4,1%*6000 + %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:\BAK\php-5.3.27\php.exe primes.benchmark.php
PHP version 5.3.27
Found 148933 prime numbers.
867ms
F:\BAK>time.bat F:\BAK\php-5.4.19\php.exe primes.benchmark.php
PHP version 5.4.19
Found 148933 prime numbers.
759ms
F:\BAK>time.bat F:\BAK\php-5.5.4\php.exe primes.benchmark.php
PHP version 5.5.4
Found 148933 prime numbers.
733ms
[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:\BAK\php-5.3.27\php.exe primes.benchmark.php
PHP version 5.3.27
Found 148933 prime numbers.
867ms
F:\BAK>time.bat F:\BAK\php-5.4.19\php.exe primes.benchmark.php
PHP version 5.4.19
Found 148933 prime numbers.
759ms
F:\BAK>time.bat F:\BAK\php-5.5.4\php.exe primes.benchmark.php
PHP version 5.5.4
Found 148933 prime numbers.
733ms