On Tue, Jan 28, 2020 at 8:33 AM nilsocket <nilsoc...@gmail.com> wrote:

> Attached two files main.c and main.go,
> both try to compute fib(40), 20 times on `x` no.of threads/goroutines.
> fib(40) is recursive.
>

Your benchmark is flawed. Goroutines are not threads. Also, the printing of
the results is included in the times you measure. You're benchmarking i/o
implementations of two libraries

Measure single-threaded implementations without printf's and see what
happens.


>
> *Prerequisites for C:*
>
>    1. libuv (https://github.com/libuv/libuv)
>
>
>
> *Compile*:
>
>    - *C :*
>       - *Unoptimized:*
>
> * gcc main.c -lpthread -luv *
>
>
>    - *Optimized:*
>       gcc-O3 main.c -lpthread -luv
>
>
>    - *Go :*
>       - go build
>
>
> *Run:*
>
>    -
>
> *C:time UV_THREADPOOL_SIZE=x ./a.out // substitute `x` with physical core
>    count *
>    -
>
> *GO:./temp x // substitute `x` with physical core count *
>
>
> Results:
>
> Thread CountC (Optimized)C (Unoptimized)GO
> 1 4.38s 11.36s 11.7s
> 4 1.12s 3.1s 2.9s
> 8 1.1s 2.9s 2.7s
>
>
> Laptop with 4 physical cores(8 logical cores).
>
> Why can't go provide Optimization flag?
> I understand go developers want compiler to be simple, but the difference
> seems too big to leave it out.
>
> But isn't there any possibility to abstract the complexity and provide
> optimization flag?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/cec68183-27d1-47cc-b106-48766a2242e6%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/cec68183-27d1-47cc-b106-48766a2242e6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqothU1hn81sFf9eJdOQonLR2kZ_E7LwjC9KsJDYw4Hddg%40mail.gmail.com.

Reply via email to