These are not useful results. Exponential recursive algorithms are known to
be very expensive. Use an iterative algorithm.
See Fibonacci Numbers and Binomial Coefficients:
$ go version
go version devel +9ef5ee911c Tue Aug 7 14:36:14 2018 +0000 linux/amd64
$ go test fib_test.go -bench=.
BenchmarkRecursive-4 1 4617595761 ns/op
BenchmarkIterative-4 50000000 28.2 ns/op
What results do you get with an iterative algorithm?
On Friday, August 10, 2018 at 6:28:01 AM UTC-4, netbrain wrote:
> So been playing around with go and wasm support on go version devel
> +479da24aac Fri Aug 10 00:47:31 2018 +0000 linux/amd64
> Curious on performance i tried implementing a Fibonacci algorithm function
> in JS and compared it to it's equivalent in GO. Calculating fib(44) takes
> 11 seconds on my machine in JS and in GO it takes 36 seconds.
> Any idea's to why I would get these results? I know wasm is very much an
> experimental feature of go, however I expected at least equal to or better
> performance than JS. Are there any browser optimizations which is running
> in my JS code which may not be in effect in wasm?
> Test code available at
You received this message because you are subscribed to the Google Groups
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.