[nbz@localhost 0]$ uname -o GNU/Linux [nbz@localhost 0]$ which echo /bin/echo [nbz@localhost 0]$ time /bin/echo 1234 1234 real 0m0.011s user 0m0.001s sys 0m0.009s [nbz@localhost 0]$ ls echo.java [nbz@localhost 0]$ cat echo.java public class echo { public static void main(String []args) { if (args != null) { System.out.printf("%s\n", args[0]); } } } [nbz@localhost 0]$ javac echo.java [nbz@localhost 0]$ which java /usr/bin/java [nbz@localhost 0]$ time /usr/bin/java echo 1234 1234 real 0m0.208s user 0m0.026s sys 0m0.181s [nbz@localhost 0]$
java写的 echo 和 linux系统自带的 echo 效率差别很大!
原文地址:http://blog.csdn.net/nibzer/article/details/45920949