[go-nuts] Re: Surprising benchmark result

2021-07-07 Thread peterGo
Revised results using the same input data for each iteration without a copy just a Filter function. i7-7500U name time/op Filter3-4 2.29µs ± 0% Filter4-4 1.51µs ± 0% i5-8250U name time/op Filter3-8 2.30µs ± 0% Filter4-8 1.53µs ± 0% Peter On Wednesday, July 7, 2021 at 11:25:11 A

[go-nuts] Re: How to pause/restart timer in a benchmark loop?

2021-07-07 Thread peterGo
On Wednesday, July 7, 2021 at 8:01:54 PM UTC-4 tapi...@gmail.com wrote: > Peter's solution exhausted my memory and hang my whole computer, and I > have to restart it. > Adjust the number of iterations (b.N), to accomodate your limited memory, For example, for 8GB use 100,000, $ go test filt

[go-nuts] Re: How to pause/restart timer in a benchmark loop?

2021-07-07 Thread tapi...@gmail.com
On Wednesday, July 7, 2021 at 8:01:54 PM UTC-4 tapi...@gmail.com wrote: > On Wednesday, July 7, 2021 at 12:32:38 PM UTC-4 jake...@gmail.com wrote: > >> It would be helpful to give more information as to why you say "This >> doesn't work"? >> But, I'm guessing that you are not seeing a decline

[go-nuts] Re: How to pause/restart timer in a benchmark loop?

2021-07-07 Thread tapi...@gmail.com
On Wednesday, July 7, 2021 at 12:32:38 PM UTC-4 jake...@gmail.com wrote: > It would be helpful to give more information as to why you say "This > doesn't work"? > But, I'm guessing that you are not seeing a decline in times when using > StartTimer/StopTimer. > > It is likely that is because t

[go-nuts] [security] Go 1.16.6 and Go 1.15.14 pre-announcement

2021-07-07 Thread Filippo Valsorda
Hello gophers, We plan to issue Go 1.16.6 and Go 1.15.14 on Monday, July 12. These are minor releases that include security fixes to the standard library. Following our new security policy , this is the pre-announcement of those releases. Alla prossima, Filippo on

[go-nuts] C Third Party Lib CGO

2021-07-07 Thread snmed
Hi all Once again I have a 3th party library which looks like this example: https://play.golang.org/p/Ue9yQ8s8Ymq and I need it to integrate in our go tool. The example is working but is still get the warning " possible misuse of unsafe.Pointer". So my questions are: 1. Can I use uintptr

[go-nuts] Re: How to pause/restart timer in a benchmark loop?

2021-07-07 Thread jake...@gmail.com
It would be helpful to give more information as to why you say "This doesn't work"? But, I'm guessing that you are not seeing a decline in times when using StartTimer/StopTimer. It is likely that is because the copy function is fast, and frequent calls to StartTimer/StopTimer involve some erro

[go-nuts] Re: How to pause/restart timer in a benchmark loop?

2021-07-07 Thread peterGo
$ go test copy_test.go -bench=. -benchmem BenchmarkFilter3-4 358167 3209 ns/op 8192 B/op 1 allocs/op $ package main import "testing" func Filter3(a []int) []int { s := make([]int, len(a)) for i := range s { s[i] += 42 } return nil } func buildOrginalData() []int {

[go-nuts] Re: How to pause/restart timer in a benchmark loop?

2021-07-07 Thread tapi...@gmail.com
This doesn't work: func BenchmarkFilter3(b *testing.B) { data := buildOrginalData() data2 := make([]int, len(data)) b.ResetTimer() for i := 0; i < b.N; i++ { b.StopTimer() copy(data2, data) b.StartTimer() _ = Filter3(data2) } } On Wednesday, Jul

[go-nuts] How to pause/restart timer in a benchmark loop?

2021-07-07 Thread tapi...@gmail.com
For example, I don't want the time consumed for "copy(data2, data)" being counted. How to achieve this? func BenchmarkFilter3(b *testing.B) { data := buildOrginalData() data2 := make([]int, len(data)) b.ResetTimer() for i := 0; i < b.N; i++ { copy(data2, data) _ =

[go-nuts] Re: Surprising benchmark result

2021-07-07 Thread tapi...@gmail.com
It is found that the test file is not written correctly. The filtered data should be reset in each loop. The corrected one: https://play.golang.org/p/yJMweZLIXAz ;D On Monday, June 7, 2021 at 10:57:19 AM UTC-4 tapi...@gmail.com wrote: > > The code: https://play.g

Re: [go-nuts] Reason to use different address space in gollvm

2021-07-07 Thread 'Than McIntosh' via golang-nuts
Hi again, Sorry for the delay, I have been offline for a while. You wrote: >Regarding address spaces, I saw that there is a pass to remove address space casts. But if I generate IR using `llvm-goc -dump-ir -enable-gc=1 test.go` for the following go file, I still can see the addrspacecast instruct

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread Levieux Michel
You cannot *per se* convert an interface or a struct to a builtin like []byte You might wanna have a look at the Bytes method of *bytes.Buffer, which returns the internal buffer of the type as a slice of bytes. Normally that would have been a good exerci

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread LetGo
Thanks for your answer!(: You are right, but I just wanted to have this one little tool in Go and I have never thought that could be that hard... ahahah By the way, it works as you said, it fixed the error! ( obviously.. ) the only thing left is to convert type *bytes.Buffer to []byte * I think

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread Levieux Michel
[Sorry forgot to hit "Reply all"] Are you trying to cast cmd.Stdout here? What you can do is: buf := new(bytes.Buffer) cmd.Stdout = buf // buf is an io.Writer so this is fine but I don't get the point of the data := foo? Maybe, before trying to convert a whole complex program in Python to a whol

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread LetGo
One of these is this: ... buf := new(bytes.Buffer) foo := buf(cmd.Stdout) // this line is 87 data := foo var i int ... pkg/conn.go:87:20: cannot call non-function buf (type *bytes.Buffer) Il giorno mercoledì 7 luglio 2021 alle 12:10:03 UTC+2 LetGo ha scritto

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread LetGo
I tried also both of them, but I got stuck into a loop of errors again.. probably I coded in the wrong way Il giorno mercoledì 7 luglio 2021 alle 11:50:51 UTC+2 Brian Candler ha scritto: > It makes no sense to convert an io.Writer to a string. > > io.Writer is an interface: any type which has a

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread Brian Candler
It makes no sense to convert an io.Writer to a string. io.Writer is an interface: any type which has a Write() method. So you can pass a string *to* a writer, to get it written somewhere, by calling the Write() method. In general, you can't get a string *from* a writer. If you google "go io.

Re: [go-nuts] Re: How to implement this in golang?

2021-07-07 Thread LetGo
Thanks for your answer!(: You are right, sorry! This is the code: https://play.golang.org/p/zEZ2HIUNffs About the lines, wow! Yes, you got them! ahah About the errors, I tried to convert ( cmd.Stdout ) io.Write to bytes/ strings, but.. I have then entered into a loop of errors... Il giorno mar