This is not a benchmark of the untyped constant expression evaluation.
The expression in the loop is performed once and thrown away *at
compile time*. The benchmark here is really:

func BenchmarkUntypedConstants(b *testing.B) {
    b.Log(0.3 - 0.1*3)
    for i := 0; i < b.N; i++ {
    }
}

On Sun, 2018-09-02 at 16:53 -0700, José Colón wrote:
> Maybe this comparison is completely wrong or unfair, but calculations
> with 
> Go untyped constants is much faster than 
> the github.com/ericlagergren/decimal package. In the end, they both
> produce 
> the same correct answer: 0 .
> 
> func BenchmarkUntypedConstants(b *testing.B) {
>     b.Log(0.3 - 0.1*3)
>     for i := 0; i < b.N; i++ {
>          _ = 0.3 - 0.1*3
>     }
> }

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to