Long 和long 性能的差別

          public class PerformanceTest {
           
          public static void main(String[] args){
               
          long time1 = System.currentTimeMillis();
               Long sum
          =0L;
               
          for(long i=0;i<Integer.MAX_VALUE;i++){
                   sum
          +=i;
               }
               System.out.println(sum);
               
          long time2 = System.currentTimeMillis();
               System.out.println((time2 
          - time1)/1000 + "秒。");
           }
          }
          上面的代碼執行了28秒
          public class PerformanceTest {
           
          public static void main(String[] args){
               
          long time1 = System.currentTimeMillis();
               
          long sum=0L;
               
          for(long i=0;i<Integer.MAX_VALUE;i++){
                   sum
          +=i;
               }
               System.out.println(sum);
               
          long time2 = System.currentTimeMillis();
               System.out.println((time2 
          - time1)/1000 + "秒。");
           }

          }
          上面的代碼執行了7秒
          第一段代碼構造了大約2的31次放的Long 實例

          posted on 2011-07-13 16:11 鍵盤動物 閱讀(463) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2011年7月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          新聞分類

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 资中县| 巴东县| 五常市| 聂拉木县| 上杭县| 梅河口市| 广昌县| 兴化市| 汉沽区| 开江县| 金山区| 丹凤县| 广昌县| 犍为县| 海原县| 海伦市| 镇巴县| 阿克| 英超| 集安市| 鸡泽县| 积石山| 天祝| 广河县| 丹东市| 阜新| 房产| 晴隆县| 桃源县| 宿州市| 环江| 四川省| 嘉善县| 周至县| 博兴县| 临泽县| 江门市| 布尔津县| 天峻县| 洛隆县| 交城县|