Go is faster than gcc?

787 views
Skip to first unread message

mattn

unread,
Jul 18, 2013, 11:51:51 PM7/18/13
to golan...@googlegroups.com
Hi all.

I found interesting benchmark result (sorry its written in japanese)


This benchmark is doing:

* open large file using mmap in C, and syscall.Mmap in go
* counting 0x00
* close

I believed that C maybe faster than go, but it seems gcc is slower than go.
I don't know why become such a result (Maybe depend on operation code cmove/simd ?)

BTW, llvm-clang is awesome

Thanks.

GreatOdinsRaven

unread,
Jul 19, 2013, 11:44:15 AM7/19/13
to golan...@googlegroups.com
These micro-benchmarks are actually not that interesting. They say nothing about the typical use cases of the language. Certain benchmarks out there *might* show that Python is within 20-30% of C on opening/closing a file in a tight loop (which in Python is thinly-wrapped C-code anyway) or whatever but that doesn't mean that "Python is as fast as C", not even close. 

I honestly don't know why people still play this benchmark game when the tests are largely meaningless or optimized specifically for a certain language's use case. 

Andy Balholm

unread,
Jul 19, 2013, 12:06:08 PM7/19/13
to golan...@googlegroups.com
I didn't read the post, but I have noticed that 6g often produces code that is faster than GCC—if GCC has optimizations turned off (which is the default). gcc -O3 is usually faster than 6g, but often not by much.

Kevin Gillette

unread,
Jul 26, 2013, 2:09:32 AM7/26/13
to golan...@googlegroups.com
On modern (or maybe even semi-modern) processors, -O3 can produce code that isn't easily cpu-cacheable, and thus slower in practice (because of mis-prediction/cache misses) than -O2. In some scenarios, -Os can actually produce faster-in-practice code than -O2, depending on the hardware involved.

John Nagle

unread,
Jul 28, 2013, 12:27:26 PM7/28/13
to golan...@googlegroups.com
On 7/18/2013 8:51 PM, mattn wrote:
> Hi all.
>
> I found interesting benchmark result (sorry its written in japanese)
>
> http://ryochack.hatenablog.com/entry/2013/07/18/201736
>
> This benchmark is doing:
>
> * open large file using mmap in C, and syscall.Mmap in go
> * counting 0x00
> * close

Here's a more realistic, and classic, benchmark.

http://www.fourmilab.ch/fbench/fbench.html

"Fbench" is a computation used in lens design, heavy
on floating point and trig functions. It's a reasonable
indication on how fast number-crunching code will run.
The correct answers are checked, and Go gets the right ones.
This benchmark has been written in over 15 languages.
For language comparisons, C is assigned a value of 1.

I ported Fbench to Go and submitted the port for testing.
The Go compiler comes in at 1.481, which is not bad.

The versions for all languages are available from that
link if you want to re-run any of the tests.

John Nagle

Nico

unread,
Jul 29, 2013, 5:02:58 AM7/29/13
to golan...@googlegroups.com
Isn't it surprising that the fastest language is Visual Basic .NET with
0.866?

(g77) FORTRAN's 1.008 is also surprising.
Reply all
Reply to author
Forward
0 new messages