不指望你靠这段程序来告诉我JAVA比C或者C++快了。
今天俺撤了。

解决方案 »

  1.   

    有些东西确实只有JIT能做到:比如中提到:
    http://www.idiom.com/~zilla/Computer/javaCbench.htmlThe compiler knows what processor it is running on, and can generate code specifically for that processor。
    JIT编译器知道什么处理器正在运行,可以产生对应此处理器的优化代码。在这一点上,C++的静态编译器肯定做不到。
    //嗯,这样就是为每个处理器都要先预编译一下,只不过每次JAVA帮你做一次,而C++要手工做,对不同的处理器做优化,看看VC的链接选项就知道了,还有LINUX包后面的i386,i586,i686就知道了,而且我觉得他优化得不够,还可以手工汇编优化。
    # The compiler knows what processor it is running on, and can generate code specifically for that processor. It knows whether (for example) the processor is a PIII or P4, if SSE2 is present, and how big the caches are. A pre-compiler on the other hand has to target the least-common-denominator processor, at least in the case of commercial software.# Because the compiler knows which classes are actually loaded and being called, it knows which methods can be de-virtualized and inlined. (Reably, modern java compilers also know how to "uncompile" inlined calls in the case where an overriding method is loaded after the JIT compilation happens.)
    这个比较复杂,不好翻译,自己看吧
    你觉得C++编译器做不到这点吗?你知道intel C++编译器现在能做得多好吗?# A dynamic compiler may also get the branch prediction hints right more often than a static compiler.
    动态编译器可以进行更准确的分支预测,从而可以提前取入指令
    你觉得C++编译器做不到这点吗?你知道intel C++编译器现在能做得多好吗?
      

  2.   

    java的博大精深不是你现在能理解的。
    将来你也许会是位高手,就冲这股执着精神,预先祝福你一下。