Thank you Volker.

I want to say that I was not trying to benchmark the two version of Go (two 
weeks ago I had go1.15.8, now 1.16). At the beginning I was trying to do 
some linear algebra with Go as a free “alternative of Matlab”, so I noted 
the difference between the exe coming from the two versions.
Now I have understand that this is not the way to measure the specific 
performance of my issue. I will learn more and also testing.

Sorry for your time, but thank you very much for your fast help.
Il giorno sabato 20 febbraio 2021 alle 17:31:24 UTC+1 Volker Dobler ha 
scritto:

> (premature send, sorry)
>
> 4. Your matrix multiplication is just a few CPU instructions, it is hard
> to measure something tiny reliable. So use larger matrixes.
> 5. You are benchmarking also how fast you can format and output
> the results to stdout. This might or might not be intentional but
> probably is just wrong.
> 6. There is no point in comparing Go 1.15 and Go 1.16 with microbenchmarks
> which do not properly measure what you think they do. Your code spends
> far too much time in a lot of things. Come up with a _proper_ benchmark
> based on testing.B and go test. Make sure this benchmark is stable. Make
> sure this benchmarks really benchmarks what you are trying to measure.
> Then redo the benchmarks 10 times and compare them doing proper
> statistics.
>
> V.
>
>
> On Saturday, 20 February 2021 at 15:48:32 UTC+1 TiT8 wrote:
>
>> Hello everyone,
>> I'm Lorenzo and I'm not a computer scientist, I have used some "Matlab" 
>> and I am new with Go (surprisingly fast, simple and elegant).
>>
>> I'm trying to do some basic operation on matrix with the "Gonum" package 
>> using vectorization. I was curious about the speed of development and the 
>> performance (repeat... surprisingly for me!). So I've tried to do some 
>> measures:
>>
>> *package main*
>>
>> *import (*
>> *    "fmt"*
>> *    "time"*
>>
>> *    "gonum.org/v1/gonum/mat <http://gonum.org/v1/gonum/mat>"*
>> *)*
>>
>> *func main() {*
>> *    p := mat.NewDense(3, 3, nil)*
>> *    a := mat.NewDense(3, 3, []float64{*
>> *        1, 2, 3, 1, 2, 3, 1, 2, 3,*
>> *    })*
>>
>> *    start := time.Now()*
>>
>> *    p.Mul(a, a)  *// element-wise
>> *    fmt.Printf("%v\n", mat.Formatted(p, mat.Prefix(""), mat.Squeeze()))*
>> *    p.Add(a, a) *
>> *    fmt.Printf("%v\n", mat.Formatted(p, mat.Prefix(""), mat.Squeeze()))*
>> *    p.MulElem(a, a)*
>> *    fmt.Printf("%v\n", mat.Formatted(p, mat.Prefix(""), mat.Squeeze()))*
>>
>> *    fmt.Println(time.Since(start))*
>> *}*
>>
>>
>> Well... when I run the "go run mat.go" command the result time is about 
>> 150 microseconds, but when I run "go build" and then execute the binary the 
>> result time is about 4 *milli*seconds. This happen when I use go1.16.
>>
>> When I use go1.15.8, on the same code, the exe is faster (about 120 
>> microseconds) then the "go run mat.go" (about 180 microseconds). One order 
>> of magnitude faster than go1.16 exe (and basic Matlab).
>>
>> So:
>>
>>    - am I in error with the code (sorry, it's all new for me)? If yes, 
>>    where is my fault?
>>    - if the "benchmark" was correct, why go1.16 build executable is 
>>    slower than go1.15.8 exe and "go run" command?
>>    - Is it my machine's fault or Gonum package or what?
>>    - Do you also have these values?  
>>    
>>
>> My pc:  HP ELITEBOOK 8560w Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz, 
>> 2201 Mhz, 4 Core(s), 8 Logical Processor(s) x64.
>> I am on the *Windows Subsystem Linux 2. * 
>>
>>
>> *Sorry for my English, I hope you understand my issue, thank you for the 
>> attention*
>>
>>
>>
>>
>>
>>

-- 
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/2cadbc63-1b00-487d-a19f-3772d3ae5487n%40googlegroups.com.

Reply via email to