免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2219 | 回复: 0
打印 上一主题 下一主题

Go1.1性能测试报告(和C差距在10%以内) [复制链接]

论坛徽章:
49
15-16赛季CBA联赛之福建
日期:2016-06-22 16:22:002015年亚洲杯之中国
日期:2015-01-23 16:25:12丑牛
日期:2015-01-20 09:39:23未羊
日期:2015-01-14 23:55:57巳蛇
日期:2015-01-06 18:21:36双鱼座
日期:2015-01-02 22:04:33午马
日期:2014-11-25 09:58:35辰龙
日期:2014-11-18 10:40:07寅虎
日期:2014-11-13 22:47:15申猴
日期:2014-10-22 15:29:50摩羯座
日期:2014-08-27 10:49:43辰龙
日期:2014-08-21 10:47:58
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-05-15 09:26 |只看该作者 |倒序浏览
  
发表于昨天(18:01)(2013-05-14 18:01) , 已有1026次阅读 ,共7个评论
目录:[ -]



最近Go1.1正式发布, 根据官方的说法, Go1.1性能比Go1.0提升基本有30%-40%, 有时更多(当然也有不明显的情况).
Go1.1的详细介绍: Go1.1新特性介绍(语言和库更完善/性能提高约30%).

这里是针对Go1.1和C语言的性能测试: 测试的重点是语言的性能, 当然也会受到标准库性能的影响.
测试环境

gcc和gc版本:
gcc -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
go version
go version go1.1 linux/amd64
测试结果
$GOROOT/test/bench/shootout/timing.sh
fasta -n 25000000
    gcc -m64 -O2 fasta.c              0.86u 0.00s 0.87r
    gc fasta                          0.85u 0.00s 0.86r
    gc_B fasta                        0.83u 0.00s 0.83r

reverse-complement < output-of-fasta-25000000
    gcc -m64 -O2 reverse-complement.c 0.45u 0.05s 0.50r
    gc reverse-complement             0.60u 0.05s 0.65r
    gc_B reverse-complement           0.55u 0.04s 0.59r

nbody -n 50000000
    gcc -m64 -O2 nbody.c -lm          5.51u 0.00s 5.52r
    gc nbody                          7.16u 0.00s 7.18r
    gc_B nbody                        7.12u 0.00s 7.14r

binary-tree 15 # too slow to use 20
    gcc -m64 -O2 binary-tree.c -lm    0.31u 0.00s 0.31r
    gc binary-tree                    1.08u 0.00s 1.07r
    gc binary-tree-freelist           0.15u 0.00s 0.15r

fannkuch 12
    gcc -m64 -O2 fannkuch.c           26.45u 0.00s 26.54r
    gc fannkuch                       35.99u 0.00s 36.08r
    gc fannkuch-parallel              73.40u 0.00s 18.58r
    gc_B fannkuch                     25.18u 0.00s 25.25r

regex-dna 100000
    gcc -m64 -O2 regex-dna.c -lpcre   0.25u 0.00s 0.26r
    gc regex-dna                      1.65u 0.00s 1.66r
    gc regex-dna-parallel             1.72u 0.01s 0.67r
    gc_B regex-dna                    1.64u 0.00s 1.65r

spectral-norm 5500
    gcc -m64 -O2 spectral-norm.c -lm  9.63u 0.00s 9.66r
    gc spectral-norm                  9.63u 0.00s 9.66r
    gc_B spectral-norm                9.63u 0.00s 9.66r

k-nucleotide 1000000
    gcc -O2 k-nucleotide.c -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -lglib-2.0  2.62u 0.00s 2.63r
    gc k-nucleotide                   2.69u 0.01s 2.71r
    gc k-nucleotide-parallel          3.02u 0.00s 0.97r
    gc_B k-nucleotide                 2.66u 0.01s 2.68r

mandelbrot 16000
    gcc -m64 -O2 mandelbrot.c        20.95u 0.00s 21.01r
    gc mandelbrot                    23.73u 0.00s 23.79r
    gc_B mandelbrot                  23.72u 0.00s 23.79r

meteor 2098
    gcc -m64 -O2 meteor-contest.c     0.05u 0.00s 0.05r
    gc meteor-contest                 0.06u 0.00s 0.07r
    gc_B meteor-contest               0.06u 0.00s 0.06r

pidigits 10000
    gcc -m64 -O2 pidigits.c -lgmp     0.77u 0.00s 0.77r
    gc pidigits                       1.45u 0.01s 1.44r
    gc_B pidigits                     1.45u 0.01s 1.43r

threadring 50000000
    gcc -m64 -O2 threadring.c -lpthread     12.05u 261.20s 216.36r
    gc threadring                           6.61u 0.00s 6.63r

chameneos 6000000
    gcc -m64 -O2 chameneosredux.c -lpthread 4.04u 21.08s 4.20r
    gc chameneosredux                       4.97u 0.00s 4.99r
测试结果说明
其中gc_B是开了-B选项, 选项的说明如下:
go tool 6g -h
usage: 6g [options] file.go...
  -+    compiling runtime
  -%    debug non-static initializers
  -A    for bootstrapping, allow 'any' type
  -B    disable bounds checking
...
应该就是禁用了Go的slice下标越界检测等特性.
测试的结果显示Go的性能已经和C语言已经非常接近了, 有极个别的甚至比C还好(binary-tree).
根据$GOROOT/test/bench/shootout/timing.log的数据, gccgo 的优化应该更好一点.
不过gccgo的标准库比gc性能可能要差一些(因此有些测试性能比gc差一些).
我电脑没有安装gccgo, 因此只有gcc/gc/gc_B三个测试结果.
关于 BenchmarksGame 的测试差异http://benchmarksgame.alioth.debian.org/u64q/go.php

BenchmarksGame的测试结果中, 有几个Go的性能很差:
Benchmark      Time Memory   Code
fasta           3×    3×      ±
spectral-norm   4×    3×      ±
binary-trees   13×    4×      ±
regex-dna     26×    ±      1/4
其中 spectral-norm 和 binary-trees 的 C 版本都开了 #pragma omp 优化(这已经不是C语言级别的比较了).
而 Go 的 binary-trees 启动了很多 goroutine, Go并发的版本和C的非并发版本比较肯定也是不合理的.
其中regex的测试主要是Go的regex标准库和C的高度优化的pcre比较. 目前Go的regex库还有待进一步的优化.
关于其他的各个程序, 实现和$GOROOT/test/bench/shootout都是有一定的差异的.

官方的测试结论http://go.googlecode.com/hg/test/bench/shootout/timing.log:
# Sep 26, 2012
# 64-bit ints, plus significantly better floating-point code.
# Interesting details:
#   Generally something in the 0-10% slower range, some (binary tree) more
#   Floating-point noticeably faster:
#       nbody -25%
#       mandelbrot -37% relative to Go 1.
#   Other:
#       regex-dna +47%
Go已经和C差距在10%以内, 有特殊场景性能甚至更好.

本文来自ChinaUnix新闻频道,如果查看原文请点:http://news.chinaunix.net/opensource/2013/0515/2764818.shtml
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP