On Tue, Nov 20, 2012 at 7:00 PM, Raymond Lau <ray...@uniteweb.net> wrote:
> ---背景
> 本来这个话题是想在 hacking 上讨论的。只为这2次周四都较忙,没有空去,所以就在slug里讨论一下了。
> 这个事情是这样的,在某个周四的晚上与Shell交流时,对他的performance项目(https://gitcafe.com/shell909090/performance)挺感兴趣的。
> 所以fork了一个,然后很快用java 实现了fibonacci。
>
> 再然后,在我的机器上,测下来的结果与Shell公布的结果相差很大,特别是C :
>
>
> make c
> ../perf -l c ./fib-c
> lang: c, filesize: 4 kB, runtime: 12.017 s, memory: 392 kB
>
> Shell的C的结果是:
> +---------+----------+---------+---------+--------+
> | lang | filesize | runtime | memory | remark |
> +---------+----------+---------+---------+--------+
> | c | 6.0 | 3.773 | 496.0 | |
>
> 甚至比java混全模式慢上一倍多:
>
> make java-server
> javac fib.java
> ../perf -l java-server java -server fib
> lang: java-server, filesize: 34 kB, runtime: 5.824 s, memory: 15376 kB
>
> 甚至与go的效率差不多:
> make go
> ../perf -l go ./fib-go
> lang: go, filesize: 1142 kB, runtime: 13.728 s, memory: 852 kB
>
> Shell公布go的结果是:
> | go | 1242.0 | 7.441 | 880.0 | |
>
> ---问题:
>
> 好吧,背景有些长,问题来了:
> 我知道这应该是gcc的问题,但是却不知道具体是gcc的神马问题?有木有玩C的大侠解解惑?
>
> ps:
> fib.c的编译参数
> gcc -O2 -o
>
> gcc 版本:
> gcc -v
> 使用内建 specs。
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.7.1/lto-wrapper
> 目标:i686-pc-linux-gnu
> 配置为:/build/src/gcc-4.7-20120721/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --disable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release
> 线程模型:posix
> gcc 版本 4.7.1 20120721 (prerelease) (GCC)
>
> java版本:
> java -version
> java version "1.6.0_24"
> OpenJDK Runtime Environment (IcedTea6 1.11.4) (ArchLinux-6.b24_1.11.4-1-i686)
> OpenJDK Server VM (build 20.0-b12, mixed mode)
>
> kernel版本:
> uname -a
> Linux uniteweb001 3.5.3-1-pae #1 SMP PREEMPT Sun Sep 9 18:09:00 UTC 2012 i686 GNU/Linux
>
> 全是用的archlinux库里的。
>
> --
> -- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
>
>
2012/11/20 Raymond Lau <ray...@uniteweb.net>:
> java 代码:
> public class fib {
>
> static public long do_fib(final int n) {
> if (n < 3)
> return 1;
> return do_fib(n - 1) + do_fib(n - 2);
> }
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> System.out.println(do_fib(45));
> }
>
> }
> 窃以为,不是java代码的问题。
> C程序的runtime时间也太长了,12s ..太夸张了些。比Shell的3.773 s相差太远。
>
> 另外在parse这个问题里,c的实现是原生的grep.. 测试这个问题时,我的结果与Shell的结果相关不大,比起java,go来确实是要高出一大截。
>
> 所以我还是怀疑是我gcc 编译的问题。。
>
>
> On Tue, Nov 20, 2012 at 11:06:57AM +0800, Chaos Eternal wrote:
> --Date: Tue, 20 Nov 2012 11:06:57 +0800
> --From: Chaos Eternal <chaose...@shlug.org>
> --To: sh...@googlegroups.com
> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
> --
> --java代码拿来。
> --
> --
> --On Tue, Nov 20, 2012 at 7:00 PM, Raymond Lau <ray...@uniteweb.net> wrote:
> --> ---背景
> --> 本来这个话题是想在 hacking 上讨论的。只为这2次周四都较忙,没有空去,所以就在slug里讨论一下了。
> --> 这个事情是这样的,在某个周四的晚上与Shell交流时,对他的performance项目(https://gitcafe.com/shell909090/performance)挺感兴趣的。
> --> 所以fork了一个,然后很快用java 实现了fibonacci。
> -->
> --> 再然后,在我的机器上,测下来的结果与Shell公布的结果相差很大,特别是C :
> -->
> -->
> --> make c
> --> ../perf -l c ./fib-c
> --> lang: c, filesize: 4 kB, runtime: 12.017 s, memory: 392 kB
> -->
> --> Shell的C的结果是:
> --> +---------+----------+---------+---------+--------+
> --> | lang | filesize | runtime | memory | remark |
> --> +---------+----------+---------+---------+--------+
> --> | c | 6.0 | 3.773 | 496.0 | |
> -->
> --> 甚至比java混全模式慢上一倍多:
> -->
> --> make java-server
> --> javac fib.java
> --> ../perf -l java-server java -server fib
> --> lang: java-server, filesize: 34 kB, runtime: 5.824 s, memory: 15376 kB
> -->
> --> 甚至与go的效率差不多:
> --> make go
> --> ../perf -l go ./fib-go
> --> lang: go, filesize: 1142 kB, runtime: 13.728 s, memory: 852 kB
> -->
> --> Shell公布go的结果是:
> --> | go | 1242.0 | 7.441 | 880.0 | |
> -->
> --> ---问题:
> -->
> --> 好吧,背景有些长,问题来了:
> --> 我知道这应该是gcc的问题,但是却不知道具体是gcc的神马问题?有木有玩C的大侠解解惑?
> -->
> --> ps:
> --> fib.c的编译参数
> --> gcc -O2 -o
> -->
> --> gcc 版本:
> --> gcc -v
> --> 使用内建 specs。
> --> COLLECT_GCC=gcc
> --> COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.7.1/lto-wrapper
> --> 目标:i686-pc-linux-gnu
> --> 配置为:/build/src/gcc-4.7-20120721/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --disable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release
> --> 线程模型:posix
> --> gcc 版本 4.7.1 20120721 (prerelease) (GCC)
> -->
> --> java版本:
> --> java -version
> --> java version "1.6.0_24"
> --> OpenJDK Runtime Environment (IcedTea6 1.11.4) (ArchLinux-6.b24_1.11.4-1-i686)
> --> OpenJDK Server VM (build 20.0-b12, mixed mode)
> -->
> --> kernel版本:
> --> uname -a
> --> Linux uniteweb001 3.5.3-1-pae #1 SMP PREEMPT Sun Sep 9 18:09:00 UTC 2012 i686 GNU/Linux
> -->
> --> 全是用的archlinux库里的。
2012/11/20 Raymond Lau <ray...@uniteweb.net>:
> java 代码:
> public class fib {
>
> static public long do_fib(final int n) {
> if (n < 3)
> return 1;
> return do_fib(n - 1) + do_fib(n - 2);
> }
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> System.out.println(do_fib(45));
> }
>
> }
> 窃以为,不是java代码的问题。
> C程序的runtime时间也太长了,12s ..太夸张了些。比Shell的3.773 s相差太远。
>
> 另外在parse这个问题里,c的实现是原生的grep.. 测试这个问题时,我的结果与Shell的结果相关不大,比起java,go来确实是要高出一大截。
>
> 所以我还是怀疑是我gcc 编译的问题。。
>
>
> On Tue, Nov 20, 2012 at 11:06:57AM +0800, Chaos Eternal wrote:
> --Date: Tue, 20 Nov 2012 11:06:57 +0800
> --From: Chaos Eternal <chaose...@shlug.org>
> --To: sh...@googlegroups.com
> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
> --
> --java代码拿来。
> --
> --
> --On Tue, Nov 20, 2012 at 7:00 PM, Raymond Lau <ray...@uniteweb.net> wrote:
> --> ---背景
> --> 本来这个话题是想在 hacking 上讨论的。只为这2次周四都较忙,没有空去,所以就在slug里讨论一下了。
> --> 这个事情是这样的,在某个周四的晚上与Shell交流时,对他的performance项目(https://gitcafe.com/shell909090/performance)挺感兴趣的。
> --> 所以fork了一个,然后很快用java 实现了fibonacci。
> -->
> --> 再然后,在我的机器上,测下来的结果与Shell公布的结果相差很大,特别是C :
> -->
> -->
> --> make c
> --> ../perf -l c ./fib-c
> --> lang: c, filesize: 4 kB, runtime: 12.017 s, memory: 392 kB
> -->
> --> Shell的C的结果是:
> --> +---------+----------+---------+---------+--------+
> --> | lang | filesize | runtime | memory | remark |
> --> +---------+----------+---------+---------+--------+
> --> | c | 6.0 | 3.773 | 496.0 | |
> -->
> --> 甚至比java混全模式慢上一倍多:
> -->
> --> make java-server
> --> javac fib.java
> --> ../perf -l java-server java -server fib
> --> lang: java-server, filesize: 34 kB, runtime: 5.824 s, memory: 15376 kB
> -->
> --> 甚至与go的效率差不多:
> --> make go
> --> ../perf -l go ./fib-go
> --> lang: go, filesize: 1142 kB, runtime: 13.728 s, memory: 852 kB
> -->
> --> Shell公布go的结果是:
> --> | go | 1242.0 | 7.441 | 880.0 | |
> -->
> --> ---问题:
> -->
> --> 好吧,背景有些长,问题来了:
> --> 我知道这应该是gcc的问题,但是却不知道具体是gcc的神马问题?有木有玩C的大侠解解惑?
> -->
> --> ps:
> --> fib.c的编译参数
> --> gcc -O2 -o
> -->
> --> gcc 版本:
> --> gcc -v
> --> 使用内建 specs。
> --> COLLECT_GCC=gcc
> --> COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.7.1/lto-wrapper
> --> 目标:i686-pc-linux-gnu
> --> 配置为:/build/src/gcc-4.7-20120721/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --disable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release
> --> 线程模型:posix
> --> gcc 版本 4.7.1 20120721 (prerelease) (GCC)
> -->
> --> java版本:
> --> java -version
> --> java version "1.6.0_24"
> --> OpenJDK Runtime Environment (IcedTea6 1.11.4) (ArchLinux-6.b24_1.11.4-1-i686)
> --> OpenJDK Server VM (build 20.0-b12, mixed mode)
> -->
> --> kernel版本:
> --> uname -a
> --> Linux uniteweb001 3.5.3-1-pae #1 SMP PREEMPT Sun Sep 9 18:09:00 UTC 2012 i686 GNU/Linux
> -->
> --> 全是用的archlinux库里的。
2012/11/20 Raymond Lau <ray...@uniteweb.net>:
>
> 最近网络一直都封了22端口,一直没能push到gitcafe上去。
> 晚上我找个地方先push上去。
>
> 我也知道多半就是gcc环境的问题了。这些时放狗过几次,一直没有头绪。
>
> 所以看看slug里有木有C方面的大牛 ,能帮忙解决下看看。
>
> PS:楼上机器老给力了。java跑3.6s.. 说实话,java 能跑到5s我都老满足了。。
>
> On Tue, Nov 20, 2012 at 11:51:30AM +0800, Chaos Eternal wrote:
> --Date: Tue, 20 Nov 2012 11:51:30 +0800
> --From: Chaos Eternal <chaose...@shlug.org>
> --To: sh...@googlegroups.com
> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
> --
> --拿你的代码我测了一下,
> --java跑3.60
> --C跑3.70
> --
> --相差不大。
> --
> --看来确实是你的环境问题。
> --
> --
> --2012/11/20 Chaos Eternal <chaose...@shlug.org>:
> --> 那个程序我跑只要3秒,为了消除硬件、环境的差异,所以需要你的代码。最好还有makefile。
> -->
> --> 2012/11/20 Raymond Lau <ray...@uniteweb.net>:
> -->> java 代码:
> -->> public class fib {
> -->>
> -->> static public long do_fib(final int n) {
> -->> if (n < 3)
> -->> return 1;
> -->> return do_fib(n - 1) + do_fib(n - 2);
> -->> }
> -->>
> -->> /**
> -->> * @param args
> -->> */
> -->> public static void main(String[] args) {
> -->> System.out.println(do_fib(45));
> -->> }
> -->>
> -->> }
> -->> 窃以为,不是java代码的问题。
> -->> C程序的runtime时间也太长了,12s ..太夸张了些。比Shell的3.773 s相差太远。
> -->>
> -->> 另外在parse这个问题里,c的实现是原生的grep.. 测试这个问题时,我的结果与Shell的结果相关不大,比起java,go来确实是要高出一大截。
> -->>
> -->> 所以我还是怀疑是我gcc 编译的问题。。
> -->>
> -->>
> -->> On Tue, Nov 20, 2012 at 11:06:57AM +0800, Chaos Eternal wrote:
> -->> --Date: Tue, 20 Nov 2012 11:06:57 +0800
> -->> --From: Chaos Eternal <chaose...@shlug.org>
> -->> --To: sh...@googlegroups.com
> -->> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
> -->> --
> -->> --java代码拿来。
> -->> --
> -->> --
> -->> --On Tue, Nov 20, 2012 at 7:00 PM, Raymond Lau <ray...@uniteweb.net> wrote:
> -->> --> ---背景
> -->> --> 本来这个话题是想在 hacking 上讨论的。只为这2次周四都较忙,没有空去,所以就在slug里讨论一下了。
> -->> --> 这个事情是这样的,在某个周四的晚上与Shell交流时,对他的performance项目(https://gitcafe.com/shell909090/performance)挺感兴趣的。
> -->> --> 所以fork了一个,然后很快用java 实现了fibonacci。
> -->> -->
> -->> --> 再然后,在我的机器上,测下来的结果与Shell公布的结果相差很大,特别是C :
> -->> -->
> -->> -->
> -->> --> make c
> -->> --> ../perf -l c ./fib-c
> -->> --> lang: c, filesize: 4 kB, runtime: 12.017 s, memory: 392 kB
> -->> -->
> -->> --> Shell的C的结果是:
> -->> --> +---------+----------+---------+---------+--------+
> -->> --> | lang | filesize | runtime | memory | remark |
> -->> --> +---------+----------+---------+---------+--------+
> -->> --> | c | 6.0 | 3.773 | 496.0 | |
> -->> -->
> -->> --> 甚至比java混全模式慢上一倍多:
> -->> -->
> -->> --> make java-server
> -->> --> javac fib.java
> -->> --> ../perf -l java-server java -server fib
> -->> --> lang: java-server, filesize: 34 kB, runtime: 5.824 s, memory: 15376 kB
> -->> -->
> -->> --> 甚至与go的效率差不多:
> -->> --> make go
> -->> --> ../perf -l go ./fib-go
> -->> --> lang: go, filesize: 1142 kB, runtime: 13.728 s, memory: 852 kB
> -->> -->
> -->> --> Shell公布go的结果是:
> -->> --> | go | 1242.0 | 7.441 | 880.0 | |
> -->> -->
> -->> --> ---问题:
> -->> -->
> -->> --> 好吧,背景有些长,问题来了:
> -->> --> 我知道这应该是gcc的问题,但是却不知道具体是gcc的神马问题?有木有玩C的大侠解解惑?
> -->> -->
> -->> --> ps:
> -->> --> fib.c的编译参数
> -->> --> gcc -O2 -o
> -->> -->
> -->> --> gcc 版本:
> -->> --> gcc -v
> -->> --> 使用内建 specs。
> -->> --> COLLECT_GCC=gcc
> -->> --> COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.7.1/lto-wrapper
> -->> --> 目标:i686-pc-linux-gnu
> -->> --> 配置为:/build/src/gcc-4.7-20120721/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --disable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release
> -->> --> 线程模型:posix
> -->> --> gcc 版本 4.7.1 20120721 (prerelease) (GCC)
> -->> -->
> -->> --> java版本:
> -->> --> java -version
> -->> --> java version "1.6.0_24"
> -->> --> OpenJDK Runtime Environment (IcedTea6 1.11.4) (ArchLinux-6.b24_1.11.4-1-i686)
> -->> --> OpenJDK Server VM (build 20.0-b12, mixed mode)
> -->> -->
> -->> --> kernel版本:
> -->> --> uname -a
> -->> --> Linux uniteweb001 3.5.3-1-pae #1 SMP PREEMPT Sun Sep 9 18:09:00 UTC 2012 i686 GNU/Linux
> -->> -->
> -->> --> 全是用的archlinux库里的。
On Tue, Nov 20, 2012 at 12:49:55PM +0800, Chaos Eternal wrote:
--Date: Tue, 20 Nov 2012 12:49:55 +0800
--Subject: Re: [shlug] 求助:c程序的效率比java还慢--放大招
--
--gcc -s
--然后上结果。
--
--
--2012/11/20 Raymond Lau <ray...@uniteweb.net>:
-->
--> 最近网络一直都封了22端口,一直没能push到gitcafe上去。
--> 晚上我找个地方先push上去。
-->
--> 我也知道多半就是gcc环境的问题了。这些时放狗过几次,一直没有头绪。
-->
--> 所以看看slug里有木有C方面的大牛 ,能帮忙解决下看看。
-->
--> PS:楼上机器老给力了。java跑3.6s.. 说实话,java 能跑到5s我都老满足了。。
-->
--> On Tue, Nov 20, 2012 at 11:51:30AM +0800, Chaos Eternal wrote:
--> --Date: Tue, 20 Nov 2012 11:51:30 +0800
--> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
--> --
--> --拿你的代码我测了一下,
--> --java跑3.60
--> --C跑3.70
--> --
--> --相差不大。
--> --
--> --看来确实是你的环境问题。
--> --
--> --
--> --2012/11/20 Chaos Eternal <chaose...@shlug.org>:
--> --> 那个程序我跑只要3秒,为了消除硬件、环境的差异,所以需要你的代码。最好还有makefile。
--> -->> java 代码:
--> -->> public class fib {
--> -->>--> -->> if (n < 3)
--> -->> static public long do_fib(final int n) {
--> -->> return 1;
--> -->> return do_fib(n - 1) + do_fib(n - 2);
--> -->> }
--> -->>
--> -->> /**
--> -->> * @param args
--> -->> */
--> -->> public static void main(String[] args) {
--> -->> System.out.println(do_fib(45));
--> -->> }
--> -->>
--> -->> }
--> -->> 窃以为,不是java代码的问题。--> -->> C程序的runtime时间也太长了,12s ..太夸张了些。比Shell的3.773 s相差太远。
--> -->>
--> -->> 另外在parse这个问题里,c的实现是原生的grep.. 测试这个问题时,我的结果与Shell的结果相关不大,比起java,go来确实是要高出一大截。
--> -->>
--> -->> 所以我还是怀疑是我gcc 编译的问题。。
--> -->>
--> -->>
--> -->> On Tue, Nov 20, 2012 at 11:06:57AM +0800, Chaos Eternal wrote:--> -->> --Date: Tue, 20 Nov 2012 11:06:57 +0800
--> -->> --From: Chaos Eternal <chaose...@shlug.org>
--> -->> --To: sh...@googlegroups.com
--> -->> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
--> -->> --
--> -->> --java代码拿来。
--> -->> --
--> -->> --
--> -->> --On Tue, Nov 20, 2012 at 7:00 PM, Raymond Lau <ray...@uniteweb.net> wrote:
--> -->> --> ---背景
--> -->> --> 本来这个话题是想在 hacking 上讨论的。只为这2次周四都较忙,没有空去,所以就在slug里讨论一下了。
--> -->> --> 这个事情是这样的,在某个周四的晚上与Shell交流时,对他的performance项目(https://gitcafe.com/shell909090/performance)挺感兴趣的。
--> -->> --> 所以fork了一个,然后很快用java 实现了fibonacci。
--> -->> -->
--> -->> --> 再然后,在我的机器上,测下来的结果与Shell公布的结果相差很大,特别是C :
--> -->> -->
--> -->> -->
--> -->> --> make c
--> -->> --> ../perf -l c ./fib-c
--> -->> --> lang: c, filesize: 4 kB, runtime: 12.017 s, memory: 392 kB
--> -->> -->
--> -->> --> Shell的C的结果是:
--> -->> --> +---------+----------+---------+---------+--------+
--> -->> --> | lang | filesize | runtime | memory | remark |
--> -->> --> +---------+----------+---------+---------+--------+
--> -->> --> | c | 6.0 | 3.773 | 496.0 | |
--> -->> -->
--> -->> --> 甚至比java混全模式慢上一倍多:
--> -->> -->
--> -->> --> make java-server
--> -->> --> javac fib.java
--> -->> --> ../perf -l java-server java -server fib
--> -->> --> lang: java-server, filesize: 34 kB, runtime: 5.824 s, memory: 15376 kB
--> -->> -->
--> -->> --> 甚至与go的效率差不多:
--> -->> --> make go
--> -->> --> ../perf -l go ./fib-go
--> -->> --> lang: go, filesize: 1142 kB, runtime: 13.728 s, memory: 852 kB
--> -->> -->
--> -->> --> Shell公布go的结果是:
--> -->> --> | go | 1242.0 | 7.441 | 880.0 | |
--> -->> -->
--> -->> --> ---问题:
--> -->> -->
--> -->> --> 好吧,背景有些长,问题来了:
--> -->> --> 我知道这应该是gcc的问题,但是却不知道具体是gcc的神马问题?有木有玩C的大侠解解惑?
--> -->> -->
--> -->> --> ps:
--> -->> --> fib.c的编译参数
--> -->> --> gcc -O2 -o
--> -->> -->
--> -->> --> gcc 版本:
--> -->> --> gcc -v
--> -->> --> 使用内建 specs。
--> -->> --> COLLECT_GCC=gcc
--> -->> --> COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.7.1/lto-wrapper
--> -->> --> 目标:i686-pc-linux-gnu
--> -->> --> 配置为:/build/src/gcc-4.7-20120721/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --disable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release
--> -->> --> 线程模型:posix
--> -->> --> gcc 版本 4.7.1 20120721 (prerelease) (GCC)
--> -->> -->
--> -->> --> java版本:
--> -->> --> java -version
--> -->> --> java version "1.6.0_24"
--> -->> --> OpenJDK Runtime Environment (IcedTea6 1.11.4) (ArchLinux-6.b24_1.11.4-1-i686)
--> -->> --> OpenJDK Server VM (build 20.0-b12, mixed mode)
--> -->> -->
--> -->> --> kernel版本:
--> -->> --> uname -a
--> -->> --> Linux uniteweb001 3.5.3-1-pae #1 SMP PREEMPT Sun Sep 9 18:09:00 UTC 2012 i686 GNU/Linux
--> -->> -->
--> -->> --> 全是用的archlinux库里的。
另外,能不能让你的mutt在回复邮件的时候,引用字符改成 > 啊。。。
2012/11/20 Raymond Lau <ray...@uniteweb.net>:
>
> gcc -S 的结果在附件
>
>
> On Tue, Nov 20, 2012 at 12:49:55PM +0800, Chaos Eternal wrote:
> --Date: Tue, 20 Nov 2012 12:49:55 +0800
> --From: Chaos Eternal <chaose...@shlug.org>
> --To: sh...@googlegroups.com
> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
> --
> --放大招
> --gcc -s
> --然后上结果。
> --
> --
> --2012/11/20 Raymond Lau <ray...@uniteweb.net>:
> -->
> --> 最近网络一直都封了22端口,一直没能push到gitcafe上去。
> --> 晚上我找个地方先push上去。
> -->
> --> 我也知道多半就是gcc环境的问题了。这些时放狗过几次,一直没有头绪。
> -->
> --> 所以看看slug里有木有C方面的大牛 ,能帮忙解决下看看。
> -->
> --> PS:楼上机器老给力了。java跑3.6s.. 说实话,java 能跑到5s我都老满足了。。
> -->
> --> On Tue, Nov 20, 2012 at 11:51:30AM +0800, Chaos Eternal wrote:
> --> --Date: Tue, 20 Nov 2012 11:51:30 +0800
> --> --From: Chaos Eternal <chaose...@shlug.org>
> --> --To: sh...@googlegroups.com
> --> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
> --> --
> --> --拿你的代码我测了一下,
> --> --java跑3.60
> --> --C跑3.70
> --> --
> --> --相差不大。
> --> --
> --> --看来确实是你的环境问题。
> --> --
> --> --
> --> --2012/11/20 Chaos Eternal <chaose...@shlug.org>:
> --> --> 那个程序我跑只要3秒,为了消除硬件、环境的差异,所以需要你的代码。最好还有makefile。
> --> -->
> --> --> 2012/11/20 Raymond Lau <ray...@uniteweb.net>:
> --> -->> java 代码:
> --> -->> public class fib {
> --> -->>
> --> -->> static public long do_fib(final int n) {
> --> -->> if (n < 3)
> --> -->> return 1;
> --> -->> return do_fib(n - 1) + do_fib(n - 2);
> --> -->> }
> --> -->>
> --> -->> /**
> --> -->> * @param args
> --> -->> */
> --> -->> public static void main(String[] args) {
> --> -->> System.out.println(do_fib(45));
> --> -->> }
> --> -->>
> --> -->> }
> --> -->> 窃以为,不是java代码的问题。
> --> -->> C程序的runtime时间也太长了,12s ..太夸张了些。比Shell的3.773 s相差太远。
> --> -->>
> --> -->> 另外在parse这个问题里,c的实现是原生的grep.. 测试这个问题时,我的结果与Shell的结果相关不大,比起java,go来确实是要高出一大截。
> --> -->>
> --> -->> 所以我还是怀疑是我gcc 编译的问题。。
> --> -->>
> --> -->>
> --> -->> On Tue, Nov 20, 2012 at 11:06:57AM +0800, Chaos Eternal wrote:
> --> -->> --Date: Tue, 20 Nov 2012 11:06:57 +0800
> --> -->> --From: Chaos Eternal <chaose...@shlug.org>
> --> -->> --To: sh...@googlegroups.com
> --> -->> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
> --> -->> --
> --> -->> --java代码拿来。
> --> -->> --
> --> -->> --
> --> -->> --On Tue, Nov 20, 2012 at 7:00 PM, Raymond Lau <ray...@uniteweb.net> wrote:
> --> -->> --> ---背景
> --> -->> --> 本来这个话题是想在 hacking 上讨论的。只为这2次周四都较忙,没有空去,所以就在slug里讨论一下了。
> --> -->> --> 这个事情是这样的,在某个周四的晚上与Shell交流时,对他的performance项目(https://gitcafe.com/shell909090/performance)挺感兴趣的。
> --> -->> --> 所以fork了一个,然后很快用java 实现了fibonacci。
> --> -->> -->
> --> -->> --> 再然后,在我的机器上,测下来的结果与Shell公布的结果相差很大,特别是C :
> --> -->> -->
> --> -->> -->
> --> -->> --> make c
> --> -->> --> ../perf -l c ./fib-c
> --> -->> --> lang: c, filesize: 4 kB, runtime: 12.017 s, memory: 392 kB
> --> -->> -->
> --> -->> --> Shell的C的结果是:
> --> -->> --> +---------+----------+---------+---------+--------+
> --> -->> --> | lang | filesize | runtime | memory | remark |
> --> -->> --> +---------+----------+---------+---------+--------+
> --> -->> --> | c | 6.0 | 3.773 | 496.0 | |
> --> -->> -->
> --> -->> --> 甚至比java混全模式慢上一倍多:
> --> -->> -->
> --> -->> --> make java-server
> --> -->> --> javac fib.java
> --> -->> --> ../perf -l java-server java -server fib
> --> -->> --> lang: java-server, filesize: 34 kB, runtime: 5.824 s, memory: 15376 kB
> --> -->> -->
> --> -->> --> 甚至与go的效率差不多:
> --> -->> --> make go
> --> -->> --> ../perf -l go ./fib-go
> --> -->> --> lang: go, filesize: 1142 kB, runtime: 13.728 s, memory: 852 kB
> --> -->> -->
> --> -->> --> Shell公布go的结果是:
> --> -->> --> | go | 1242.0 | 7.441 | 880.0 | |
> --> -->> -->
> --> -->> --> ---问题:
> --> -->> -->
> --> -->> --> 好吧,背景有些长,问题来了:
> --> -->> --> 我知道这应该是gcc的问题,但是却不知道具体是gcc的神马问题?有木有玩C的大侠解解惑?
> --> -->> -->
> --> -->> --> ps:
> --> -->> --> fib.c的编译参数
> --> -->> --> gcc -O2 -o
> --> -->> -->
> --> -->> --> gcc 版本:
> --> -->> --> gcc -v
> --> -->> --> 使用内建 specs。
> --> -->> --> COLLECT_GCC=gcc
> --> -->> --> COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.7.1/lto-wrapper
> --> -->> --> 目标:i686-pc-linux-gnu
> --> -->> --> 配置为:/build/src/gcc-4.7-20120721/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --disable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release
> --> -->> --> 线程模型:posix
> --> -->> --> gcc 版本 4.7.1 20120721 (prerelease) (GCC)
> --> -->> -->
> --> -->> --> java版本:
> --> -->> --> java -version
> --> -->> --> java version "1.6.0_24"
> --> -->> --> OpenJDK Runtime Environment (IcedTea6 1.11.4) (ArchLinux-6.b24_1.11.4-1-i686)
> --> -->> --> OpenJDK Server VM (build 20.0-b12, mixed mode)
> --> -->> -->
> --> -->> --> kernel版本:
> --> -->> --> uname -a
> --> -->> --> Linux uniteweb001 3.5.3-1-pae #1 SMP PREEMPT Sun Sep 9 18:09:00 UTC 2012 i686 GNU/Linux
> --> -->> -->
> --> -->> --> 全是用的archlinux库里的。
再丑也得上代码。
我的代码已经很丑了。
2012/11/20 David pulq <pulq...@gmail.com>:
> 跟你这个差不多,只是写得丑一点。
> 话说这个测试就是比较各种语言/编译器/解释器对递归的优化, 做个加法什么语言跑起来速度都那样。
拿迭代跟递归比当然没啥好比,但是这个代码没有被自动优化的可能性(除了上面某楼说的那个很仙的办法),所以测的是*函数调用*的速度,不是*递归*的速度。
很久以前学生的时候记得尾递归是可以被编译器自动优化的,可惜忘记了具体条件了。
你觉得g++有可能每看到一个typedef就递归一次?
显然还是迭代啊。
没有栈
如果有这样一种语言,自动把代码改写成尾递归,然后再按尾递归进行优化,就可以在本轮胜出。
反正结果是整数你随便取个整不就好了……
不是有矩阵版……
http://en.wikipedia.org/wiki/Fibonacci_number#Matrix_form
根本没解决无理数的问题
怎麼沒解決,你算一個整數組成的矩陣的乘法需要無理數?
这个答案好像给我发现了,因为考试时没有这题啊!
手机没法撤销发送……最后一个是 f(n-1)
另外,那个矩阵乘法是满足结合律的,所以计算 pow(A, 2n)可以先算 pow(A,n)然后 计算 pow(A,n)*pow(A,n) ;
A=(1 1; 1 0) , sicp里面讲了的,hiahiahia.
回头上代码。
def fib(n):
if n <= 2: return 1
a = [[0, 1], [1, 1]]
y = [[1, 0], [0, 1]]
while n > 0 :
if n % 2 == 1:
y = mul(y, a)
a = mul(a, a)
n /= 2
return y[0][1]
n = 1000000
print "fib[%d]=%d" % (n, fib(n))
赞
(define (fib-fast nc)
(define (iter a b c d n)
(cond ((= n 0) b)
((even? n) (iter a
b
(+ (* c c) (* d d))
(+ (* d d) (* 2 c d))
(/ n 2)))
(#t (iter (+ (* b d) (* a d) (* a c))
(+ (* b c) (* a d))
c
d
(- n 1)))))
(iter 1 0 0 1 nc))
On Wed, Nov 21, 2012 at 2:44 PM, 依云 <lily...@gmail.com> wrote:
c++完胜,编译期间计算。#include<stdio.h>template<int v>struct fib{enum{result = fib<v-1>::result + fib<v-2>::result,};};template<>struct fib<1>{enum{result = 1,};};template<>struct fib<2>{enum{result = 1,};};int main(){printf("%d\n",fib<45>::result);return 0;}--不学无术
2012/11/20 Chaos Eternal <chaose...@shlug.org>我用这个逻辑放到我那个fib-gmp-opt里面去试了一下,貌似反而慢了。
现在不能push, 晚上再push。
2012/11/20 Chaos Eternal <chaose...@shlug.org>:
> 赞一下 STACK[i & 1] = STACK[(i - 1) & 0x1] + STACK[(i-2) &0x1]; 不知道跟
> STACK[i & 1] = STACK[!(i & 0x1)] + STACK[i & 0x1]; 比那个更快。
>
> 吐一下那个if, 多余!
>
> 2012/11/20 David pulq <pulq...@gmail.com>:
>> #include<stdlib.h>
>> #include<stdio.h>
>> #define likely(x) __builtin_expect((x),1)
>> #define unlikely(x) __builtin_expect((x),0)
>>
>> static long STACK[2];
>> static long do_fib_s(int n)
>> {
>> int i;
>> STACK[0] = 0;
>> STACK[1] = 1;
>> for (i=2; i < n+1; i++) {
>> if (unlikely(i < 3)) {
>> STACK[i & 0x1] = 1;
>> } else {
>> STACK[i & 1] = STACK[(i - 1) & 0x1] + STACK[(i-2) &
>> 0x1];
>> }
>> }
>> return STACK[n & 0x1];
>>
>> }
>>
>> int main(int argc, char *argv[])
>> {
>> //printf("fib:%ld\n", do_fib(45));
>> printf("fib_s:%ld\n", do_fib_s(45));
>> return 0;
>> }
>>
>>
>> On Tuesday, November 20, 2012 4:56:40 PM UTC+8, Chaos Eternal wrote:
>>>
>>> 再丑也得上代码。
>>> 我的代码已经很丑了。
>>>
>>> 2012/11/20 David pulq <pulq...@gmail.com>:
>>> > 跟你这个差不多,只是写得丑一点。
>>> > 话说这个测试就是比较各种语言/编译器/解释器对递归的优化, 做个加法什么语言跑起来速度都那样。
>>>
>>> 拿迭代跟递归比当然没啥好比,但是这个代码没有被自动优化的可能性(除了上面某楼说的那个很仙的办法),所以测的是*函数调用*的速度,不是*递归*的速度。
>>>
>>> 当然,shell的这个目的本身有很多槽点,回头慢慢吐之。
>>>
>>> >
>>> >
>>> > On Tuesday, November 20, 2012 4:38:15 PM UTC+8, Chaos Eternal wrote:
>>> >>
>>> >> https://gitcafe.com/chaoseternal/performance/tree/master/fib-iter
>>> >>
>>> >> 跑我这个版本吧。
>>> >>
>>> >>
>>> >> 2012/11/20 依云 <lily...@gmail.com>:
>>> >> >>>> time java fib
>>> >> > 1134903170
>>> >> > java fib 4.85s user 0.01s system 99% cpu 4.879 total
>>> >> >>>> time ./fib-c
>>> >> > 1134903170
>>> >> > ./fib-c 2.40s user 0.00s system 99% cpu 2.405 total
>>> >> >
>>> >> > 另外,同讨厌引用字符不规矩的 :-(
>>> >> >
>>> >> > On Tue, Nov 20, 2012 at 01:54:40PM +0800, Chaos Eternal wrote:
>>> >> >> 看了一下,除了是32位的,好像看不出啥。
>>> >> >>
>>> >> >> 另外,能不能让你的mutt在回复邮件的时候,引用字符改成 > 啊。。。
>>> >> >>
>>> >> >> 2012/11/20 Raymond Lau <ray...@uniteweb.net>:
>>> >> >> >
>>> >> >> > gcc -S 的结果在附件
>>> >> >> >
>>> >> >> >
>>> >> >> > On Tue, Nov 20, 2012 at 12:49:55PM +0800, Chaos Eternal wrote:
>>> >> >> > --Date: Tue, 20 Nov 2012 12:49:55 +0800
>>> >> >> > --From: Chaos Eternal <chaose...@shlug.org>
>>> >> >> > --To: sh...@googlegroups.com
>>> >> >> > --Subject: Re: [shlug] 求助:c程序的效率比java还慢
>>> >> >> > --
>>> >> >> > --放大招
>>> >> >> > --gcc -s
>>> >> >> > --然后上结果。
>>> >> >> > --
>>> >> >> > --
>>> >> >> > --2012/11/20 Raymond Lau <ray...@uniteweb.net>:
>>> >> >> > -->
>>> >> >> > --> 最近网络一直都封了22端口,一直没能push到gitcafe上去。
>>> >> >> > --> 晚上我找个地方先push上去。
>>> >> >> > -->
>>> >> >> > --> 我也知道多半就是gcc环境的问题了。这些时放狗过几次,一直没有头绪。
>>> >> >> > -->
>>> >> >> > --> 所以看看slug里有木有C方面的大牛 ,能帮忙解决下看看。
>>> >> >> > -->
>>> >> >> > --> PS:楼上机器老给力了。java跑3.6s.. 说实话,java 能跑到5s我都老满足了。。
>>> >> >> > -->
>>> >> >> > --> On Tue, Nov 20, 2012 at 11:51:30AM +0800, Chaos Eternal wrote:
>>> >> >> > --> --Date: Tue, 20 Nov 2012 11:51:30 +0800
>>> >> >> > --> --From: Chaos Eternal <chaose...@shlug.org>
>>> >> >> > --> --To: sh...@googlegroups.com
>>> >> >> > --> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
>>> >> >> > --> --
>>> >> >> > --> --拿你的代码我测了一下,
>>> >> >> > --> --java跑3.60
>>> >> >> > --> --C跑3.70
>>> >> >> > --> --
>>> >> >> > --> --相差不大。
>>> >> >> > --> --
>>> >> >> > --> --看来确实是你的环境问题。
>>> >> >> > --> --
>>> >> >> > --> --
>>> >> >> > --> --2012/11/20 Chaos Eternal <chaose...@shlug.org>:
>>> >> >> > --> --> 那个程序我跑只要3秒,为了消除硬件、环境的差异,所以需要你的代码。最好还有makefile。
>>> >> >> > --> -->
>>> >> >> > --> --> 2012/11/20 Raymond Lau <ray...@uniteweb.net>:
>>> >> >> > --> -->> java 代码:
>>> >> >> > --> -->> public class fib {
>>> >> >> > --> -->>
>>> >> >> > --> -->> static public long do_fib(final int n) {
>>> >> >> > --> -->> if (n < 3)
>>> >> >> > --> -->> return 1;
>>> >> >> > --> -->> return do_fib(n - 1) + do_fib(n - 2);
>>> >> >> > --> -->> }
>>> >> >> > --> -->>
>>> >> >> > --> -->> /**
>>> >> >> > --> -->> * @param args
>>> >> >> > --> -->> */
>>> >> >> > --> -->> public static void main(String[] args) {
>>> >> >> > --> -->> System.out.println(do_fib(45));
>>> >> >> > --> -->> }
>>> >> >> > --> -->>
>>> >> >> > --> -->> }
>>> >> >> > --> -->> 窃以为,不是java代码的问题。
>>> >> >> > --> -->> C程序的runtime时间也太长了,12s ..太夸张了些。比Shell的3.773 s相差太远。
>>> >> >> > --> -->>
>>> >> >> > --> -->> 另外在parse这个问题里,c的实现是原生的grep..
>>> >> >> > 测试这个问题时,我的结果与Shell的结果相关不大,比起java,go来确实是要高出一大截。
>>> >> >> > --> -->>
>>> >> >> > --> -->> 所以我还是怀疑是我gcc 编译的问题。。
>>> >> >> > --> -->>
>>> >> >> > --> -->>
>>> >> >> > --> -->> On Tue, Nov 20, 2012 at 11:06:57AM +0800, Chaos Eternal
>>> >> >> > wrote:
>>> >> >> > --> -->> --Date: Tue, 20 Nov 2012 11:06:57 +0800
>>> >> >> > --> -->> --From: Chaos Eternal <chaose...@shlug.org>
>>> >> >> > --> -->> --To: sh...@googlegroups.com
>>> >> >> > --> -->> --Subject: Re: [shlug] 求助:c程序的效率比java还慢
>>> >> >> > --> -->> --
>>> >> >> > --> -->> --java代码拿来。
>>> >> >> > --> -->> --
>>> >> >> > --> -->> --
>>> >> >> > --> -->> --On Tue, Nov 20, 2012 at 7:00 PM, Raymond Lau
>>> >> >> > <ray...@uniteweb.net> wrote:
>>> >> >> > --> -->> --> ---背景
>>> >> >> > --> -->> --> 本来这个话题是想在 hacking
>>> >> >> > 上讨论的。只为这2次周四都较忙,没有空去,所以就在slug里讨论一下了。
>>> >> >> > --> -->> -->
>>> >> >> >
>>> >> >> > 这个事情是这样的,在某个周四的晚上与Shell交流时,对他的performance项目(https://gitcafe.com/shell909090/performance)挺感兴趣的。
>>> >> >> > --> -->> --> 所以fork了一个,然后很快用java 实现了fibonacci。
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> 再然后,在我的机器上,测下来的结果与Shell公布的结果相差很大,特别是C :
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> make c
>>> >> >> > --> -->> --> ../perf -l c ./fib-c
>>> >> >> > --> -->> --> lang: c, filesize: 4 kB, runtime: 12.017 s, memory:
>>> >> >> > 392
>>> >> >> > kB
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> Shell的C的结果是:
>>> >> >> > --> -->> --> +---------+----------+---------+---------+--------+
>>> >> >> > --> -->> --> | lang | filesize | runtime | memory | remark |
>>> >> >> > --> -->> --> +---------+----------+---------+---------+--------+
>>> >> >> > --> -->> --> | c | 6.0 | 3.773 | 496.0 | |
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> 甚至比java混全模式慢上一倍多:
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> make java-server
>>> >> >> > --> -->> --> javac fib.java
>>> >> >> > --> -->> --> ../perf -l java-server java -server fib
>>> >> >> > --> -->> --> lang: java-server, filesize: 34 kB, runtime: 5.824 s,
>>> >> >> > memory: 15376 kB
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> 甚至与go的效率差不多:
>>> >> >> > --> -->> --> make go
>>> >> >> > --> -->> --> ../perf -l go ./fib-go
>>> >> >> > --> -->> --> lang: go, filesize: 1142 kB, runtime: 13.728 s,
>>> >> >> > memory:
>>> >> >> > 852 kB
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> Shell公布go的结果是:
>>> >> >> > --> -->> --> | go | 1242.0 | 7.441 | 880.0 | |
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> ---问题:
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> 好吧,背景有些长,问题来了:
>>> >> >> > --> -->> --> 我知道这应该是gcc的问题,但是却不知道具体是gcc的神马问题?有木有玩C的大侠解解惑?
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> ps:
>>> >> >> > --> -->> --> fib.c的编译参数
>>> >> >> > --> -->> --> gcc -O2 -o
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> gcc 版本:
>>> >> >> > --> -->> --> gcc -v
>>> >> >> > --> -->> --> 使用内建 specs。
>>> >> >> > --> -->> --> COLLECT_GCC=gcc
>>> >> >> > --> -->> -->
>>> >> >> >
>>> >> >> > COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.7.1/lto-wrapper
>>> >> >> > --> -->> --> 目标:i686-pc-linux-gnu
>>> >> >> > --> -->> --> 配置为:/build/src/gcc-4.7-20120721/configure
>>> >> >> > --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
>>> >> >> > --mandir=/usr/share/man --infodir=/usr/share/info
>>> >> >> > --with-bugurl=https://bugs.archlinux.org/
>>> >> >> > --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++
>>> >> >> > --enable-shared
>>> >> >> > --enable-threads=posix --with-system-zlib --enable-__cxa_atexit
>>> >> >> > --disable-libunwind-exceptions --enable-clocale=gnu
>>> >> >> > --disable-libstdcxx-pch
>>> >> >> > --enable-libstdcxx-time --enable-gnu-unique-object
>>> >> >> > --enable-linker-build-id
>>> >> >> > --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check
>>> >> >> > --disable-cloog-version-check --enable-lto --enable-gold
>>> >> >> > --enable-ld=default
>>> >> >> > --enable-plugin --with-plugin-ld=ld.gold
>>> >> >> > --with-linker-hash-style=gnu
>>> >> >> > --disable-multilib --disable-libssp --disable-build-with-cxx
>>> >> >> > --disable-build-poststage1-with-cxx --enable-checking=release
>>> >> >> > --> -->> --> 线程模型:posix
>>> >> >> > --> -->> --> gcc 版本 4.7.1 20120721 (prerelease) (GCC)
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> java版本:
>>> >> >> > --> -->> --> java -version
>>> >> >> > --> -->> --> java version "1.6.0_24"
>>> >> >> > --> -->> --> OpenJDK Runtime Environment (IcedTea6 1.11.4)
>>> >> >> > (ArchLinux-6.b24_1.11.4-1-i686)
>>> >> >> > --> -->> --> OpenJDK Server VM (build 20.0-b12, mixed mode)
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> kernel版本:
>>> >> >> > --> -->> --> uname -a
>>> >> >> > --> -->> --> Linux uniteweb001 3.5.3-1-pae #1 SMP PREEMPT Sun
>>> >> >> > Sep
>>> >> >> > 9 18:09:00 UTC 2012 i686 GNU/Linux
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> 全是用的archlinux库里的。
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --> --
>>> >> >> > --> -->> --> -- You received this message because you are
>>> >> >> > subscribed
>>> >> >> > to the Google Groups Shanghai Linux User Group group. To post to
>>> >> >> > this group,
>>> >> >> > send email to sh...@googlegroups.com. To unsubscribe from this
>>> >> >> > group, send
>>> >> >> > email to shlug+un...@googlegroups.com. For more options, visit
>>> >> >> > this group at
>>> >> >> > https://groups.google.com/d/forum/shlug?hl=zh-CN
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> -->
>>> >> >> > --> -->> --
>>> >> >> > --> -->> ----
>>> >> >> > --> -->> ---- You received this message because you are subscribed
>>> >> >> > to
>>> >> >> > the Google Groups Shanghai Linux User Group group. To post to this
>>> >> >> > group,
>>> >> >> > send email to sh...@googlegroups.com. To unsubscribe from this
>>> >> >> > group, send
>>> >> >> > email to shlug+un...@googlegroups.com. For more options, visit
>>> >> >> > this group at
>>> >> >> > https://groups.google.com/d/forum/shlug?hl=zh-CN
>>> >> >> > --> -->> --
>>> >> >> > --> -->> --
>>> >> >> > --> -->>
>>> >> >> > --> -->> --
>>> >> >> > --> -->> Raymond Lau
>>> >> >> > --> -->>
>>> >> >> > --> -->> --
>>> >> >> > --> -->> -- You received this message because you are subscribed
>>> >> >> > to
>>> >> >> > the Google Groups Shanghai Linux User Group group. To post to this
>>> >> >> > group,
>>> >> >> > send email to sh...@googlegroups.com. To unsubscribe from this
>>> >> >> > group, send
>>> >> >> > email to shlug+un...@googlegroups.com. For more options, visit
>>> >> >> > this group at
>>> >> >> > https://groups.google.com/d/forum/shlug?hl=zh-CN
>>> >> >> > --> -->>
>>> >> >> > --> -->>
>>> >> >> > --> --
>>> >> >> > --> ----
>>> >> >> > --> ---- You received this message because you are subscribed to
>>> >> >> > the
>>> >> >> > Google Groups Shanghai Linux User Group group. To post to this
>>> >> >> > group, send
>>> >> >> > email to sh...@googlegroups.com. To unsubscribe from this group,
>>> >> >> > send email
>>> >> >> > to shlug+un...@googlegroups.com. For more options, visit this
>>> >> >> > group at
>>> >> >> > https://groups.google.com/d/forum/shlug?hl=zh-CN
>>> >> >> > --> --
>>> >> >> > --> --
>>> >> >> > -->
>>> >> >> > --> --
>>> >> >> > --> Raymond Lau
>>> >> >> > -->
>>> >> >> > --> --
>>> >> >> > --> -- You received this message because you are subscribed to the
>>> >> >> > Google Groups Shanghai Linux User Group group. To post to this
>>> >> >> > group, send
>>> >> >> > email to sh...@googlegroups.com. To unsubscribe from this group,
>>> >> >> > send email
>>> >> >> > to shlug+un...@googlegroups.com. For more options, visit this
>>> >> >> > group at
>>> >> >> > https://groups.google.com/d/forum/shlug?hl=zh-CN
>>> >> >> > -->
>>> >> >> > -->
>>> >> >> > --
>>> >> >> > ----
>>> >> >> > ---- You received this message because you are subscribed to the
>>> >> >> > Google Groups Shanghai Linux User Group group. To post to this
>>> >> >> > group, send
>>> >> >> > email to sh...@googlegroups.com. To unsubscribe from this group,
>>> >> >> > send email
>>> >> >> > to shlug+un...@googlegroups.com. For more options, visit this
>>> >> >> > group at
>>> >> >> > https://groups.google.com/d/forum/shlug?hl=zh-CN
>>> >> >> > --
>>> >> >> > --
>>> >> >> >
>>> >> >> > --
>>> >> >> > Raymond Lau