First they ignore you
          then they ridicule you
          then they fight you
          then you win
              -- Mahatma Gandhi
          Chinese => English     英文 => 中文             
          隨筆-221  評論-1047  文章-0  trackbacks-0
          Groovy1.1 beta-3終于發(fā)布了,出于好奇,我借用了emu同學的8皇后代碼來測試一下Groovy1.1 beta-3和Groovy1.1 beta-2的性能差異,
          利用Groovy1.1 beta-3和Groovy1.1 beta-2將8皇后代碼各運行10次,記錄下運行程序所耗時間,結(jié)果如下:


          12345678910????? AVG
          Groovy 1.1-beta212501250131312031359121912181297128113441273.4
          Groovy 1.1-beta31156107810151047104711561094103111579841076.5


          經(jīng)過計算,Groovy1.1 beta-3的性能提升了15.5%,期待Groovy1.1 final :)

          此外值得一提的是,IBM的ProjectZero團隊正在為Groovy改善Eclipse插件,Sun也向Groovy Team施加援手提供服務(wù)器供其使用,JetBrains的IntelliJ IDEA Groovy & Grails插件milestone2版本已經(jīng)發(fā)布。

          測試所用的8皇后代碼:
          q = 8
          i = new int[q]
          count = 0

          def scan(n){
          ??? if (n == q){
          ??????? println(i.toList())
          ??????? count++
          ??????? return
          ??? }
          ??? i[n]=0
          ??? while (i[n] < q){
          ??????? i[n] = i[n]+1
          ??????? if (check(n))
          ??????????? scan(n + 1)
          ??? }
          }
          def check(n){
          ??? if (n > 0)
          ??????? for (j in 0..<n)
          ??????????? if (i[j] == i[n] || i[j] - i[n] == j - n || i[j] - i[n] == n - j)
          ??????????????? return false
          ??? return true
          }

          long t1 = System.currentTimeMillis()
          scan(0)
          long t2 = System.currentTimeMillis()
          println("total time:" + ( t2 - t1))? // 耗時
          println("total results:" + count)


          下載地址:http://dist.groovy.codehaus.org/distributions/groovy-binary-1.1-beta-3.zip

          附:朝花夕拾——Groovy & Grails
          posted on 2007-09-21 20:33 山風小子 閱讀(1045) 評論(2)  編輯  收藏 所屬分類: Groovy & Grails
          主站蜘蛛池模板: 玉田县| 察隅县| 雷山县| 古交市| 微山县| 长春市| 娱乐| 邵东县| 玛曲县| 敦化市| 丰都县| 金堂县| 巴塘县| 射洪县| 尼玛县| 绿春县| 靖边县| 通渭县| 赤水市| 肥城市| 永安市| 武川县| 高雄市| 普宁市| 镇雄县| 齐河县| 阜新| 黔江区| 佛学| 老河口市| 泗洪县| 阿拉尔市| 宜丰县| 台中市| 江山市| 桃源县| 汉源县| 塔城市| 桐庐县| 桂林市| 大邑县|