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 山风小子 阅读(1036) 评论(2)  编辑  收藏 所属分类: Groovy & Grails