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終于發布了,出于好奇,我借用了emu同學的8皇后代碼來測試一下Groovy1.1 beta-3和Groovy1.1 beta-2的性能差異,
          利用Groovy1.1 beta-3和Groovy1.1 beta-2將8皇后代碼各運行10次,記錄下運行程序所耗時間,結果如下:


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


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

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

          測試所用的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 山風小子 閱讀(1047) 評論(2)  編輯  收藏 所屬分類: Groovy & Grails
          主站蜘蛛池模板: 清水河县| 永嘉县| 龙井市| 上饶县| 溆浦县| 磴口县| 岐山县| 芷江| 廉江市| 临潭县| 香港 | 定远县| 龙口市| 永川市| 拜城县| 临泉县| 阿拉善右旗| 衡南县| 唐河县| 苍山县| 远安县| 宜阳县| 永平县| 江安县| 博兴县| 灵丘县| 贡山| 石林| 工布江达县| 含山县| 万山特区| 合山市| 汕尾市| 青阳县| 资阳市| 隆尧县| 上栗县| 淅川县| 德江县| 鄯善县| 阜新|