Re: [go-nuts] Understanding benchstat's output

2021-07-27 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2021-07-27 at 20:55 -0700, Tong Sun wrote: > Hi, > > I'm trying to understand the benchstat's output. > The benchstat that I have is fresh from golang.org/x/perf/cmd/, > installed hours ago. > > This is understandable: > > nameold time/opnew time/opdelta > FormatEmoji-2

Re: [go-nuts] Understanding benchstat's output

2021-07-27 Thread Kurtis Rader
You didn't show us the actual commands you are running to produce the two log files. It is also unclear why you expect benchstat to report a difference. In other words: insufficient information for anyone to make even a guess why benchstat isn't producing the output you expect. On Tue, Jul 27, 202

[go-nuts] Understanding benchstat's output

2021-07-27 Thread Tong Sun
Hi, I'm trying to understand the benchstat's output. The benchstat that I have is fresh from golang.org/x/perf/cmd/, installed hours ago. This is understandable: nameold time/opnew time/opdelta FormatEmoji-2 1.79µs ± 0%1.82µs ± 1% ~ (p=0.100 n=3+3) FormatEmoj

Re: [go-nuts] use delve to debug golang with 'next' will skip some step

2021-07-27 Thread jake...@gmail.com
Was the code built with optimizations disabled? On Tuesday, July 27, 2021 at 1:57:17 PM UTC-4 林 子鹏 wrote: > When I use delve to debug this project(dlv debug t.go): > > //t.gopackage main > import ( > "fmt" > "os" > "reflect" > "unsafe" > ) > func main() { > s1 := make([]uint8

Re: [go-nuts] Does the time cost of the mark phase in gc is mainly depending on the amount of the living objects and has very little to do with the amount of unused objects?

2021-07-27 Thread Ian Lance Taylor
On Tue, Jul 27, 2021 at 4:56 AM rmfr wrote: > > Hi, I'm reading the GC implementation of Golang, and some questions have come > to me. As the title described: > > Proposition 1: > The time cost of the mark phase in GC is mainly depending on the amount > of the living objects. > > Proposition

Re: [go-nuts] Website: add features international books

2021-07-27 Thread Frederic Marand
And here is the PR https://github.com/golang/website/pull/76 I chose 5 books to have a second row, by decreasing number of language speakers, subject to the actual number of original books in that language (not translations), skipping books that didn't exist or weren't books, from the wiki book

Re: [go-nuts] runtime : Callers and CallersFrames is expensive , can i cached CallersFrames 's result .

2021-07-27 Thread 'Ian Cottrell' via golang-nuts
Not sure if it the same issue, but one problem is that runtime.CallersFrames returns a *Frames, which means it does an allocation. It would be nice to have a call that either returned a Frames by value, or one that takes a frame to reset and fill in. On Tuesday, 27 July 2021 at 16:18:17 UTC-4 I

Re: [go-nuts] runtime : Callers and CallersFrames is expensive , can i cached CallersFrames 's result .

2021-07-27 Thread Ian Lance Taylor
Sorry, I'm not sure exactly what you are asking. The value returned by runtime.Callers is just a slice, and the value returned by runtime.CallersFrames is an ordinary value. It's fine to save those values however you like. Ian -- You received this message because you are subscribed to the Goog

Re: [go-nuts] Re: A peculiar sort problem

2021-07-27 Thread James
It could be that .NET is using some locale based collation. Seems like a lot of machinery, but might do the trick https://pkg.go.dev/golang.org/x/text@v0.3.6/collate On Wed, 28 Jul 2021 at 06:52, jake...@gmail.com wrote: > Personally I would be careful about assuming that was the only sorting >

[go-nuts] Re: A peculiar sort problem

2021-07-27 Thread Brian Candler
As a complete guess: perhaps the .NET sorter is replacing underscore with space before sorting? You'll need to do some further experimentation to prove or disprove this theory. But if it's true, you can change your Less function in a corresponding way. Of course, that still begs the question

Re: [go-nuts] Website: add features international books

2021-07-27 Thread FGM at GMail
Following Ian Lance Taylor's suggestion, here is an issue on the go tracker https://github.com/golang/go/issues/47426 Le mer. 21 juil. 2021 à 05:43, Ian Lance Taylor a écrit : > On Mon, Jul 12, 2021 at 8:12 AM Frederic Marand > wrote: > > > > Currently, although Go has a broad international au

[go-nuts] Re: A peculiar sort problem

2021-07-27 Thread Tamás Gulácsi
First, sort all the bytes (0-255) with Go and .Net, and compare them. For Unicode-unaware sorting, that'd be enough: create a mapping between the two tables, replace all the bytes in the Go's input before sort (or use a Less that does the translation), thus replicating the .NET sort order. ampl

[go-nuts] Re: A peculiar sort problem

2021-07-27 Thread jake...@gmail.com
Personally I would be careful about assuming that was the only sorting difference. Unless you have checked every Unicode character, there could be other hidden 'special cases'. If it *really *mattered, personally, I would dig into the .NET library source code and see what algorithm or system cal

[go-nuts] runtime : Callers and CallersFrames is expensive , can i cached CallersFrames 's result .

2021-07-27 Thread kor zhao
help -- 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

[go-nuts] GOOS=js/GOARCH=wasm

2021-07-27 Thread W. Michael Petullo
I have been building applications using the GOOS=js/GOARCH=wasm for around two years. I really like being able to write both client and server code in Go. I have four questions that I have not yet found a clear answer for: (1) The syscall/js package is marked EXPERIMENTAL. Is there any consensus

[go-nuts] How to pick a random number every time from a list

2021-07-27 Thread hyogy hyogy
The goal: pick a random number from a list every time a chunk is generated Python code example to make it more clear. I have this list: ``` listbytes = [87, 88, 89, 90] ``` And this function which splits the data: ``` def chunks(lst, n): "Yield successive chunks from lst, where n is a list of

[go-nuts] A peculiar sort problem

2021-07-27 Thread Tobias Klausmann
Hi! I am writing a tool that handles files and generates some sorted output. Since this tool is to be a replacement for part of another system (written in C#/.NET), the output must be a byte-exact duplicate. The existing system generates some checksums and filenames in a stable sorted order, lik

[go-nuts] Re: [ANN] astilectron - Build cross platform GUI apps with GO and Electron (HTML/JS/CSS)

2021-07-27 Thread 이현수
Thanks for the good work! Recently, I'm working on making a desktop app with astilectron. Now I'm going over the code of go-astilectron-demo. It works perfectly meeting my needs. The question is that How can I debug the code when the bundler is used? Can I println my custom debug message to a co

Re: [go-nuts] unsafe string to []byte

2021-07-27 Thread Robert Engels
Agreed. If a Go library uses unsafe I avoid it. > On Jul 27, 2021, at 9:54 AM, 'Axel Wagner' via golang-nuts > wrote: > >  >> On Tue, Jul 27, 2021 at 4:15 PM Steve Roth wrote: > >> The implementation of io.WriteString appears to allocate a new byte slice >> and copy the string into it: >>

Re: [go-nuts] unsafe string to []byte

2021-07-27 Thread 'Axel Wagner' via golang-nuts
On Tue, Jul 27, 2021 at 4:15 PM Steve Roth wrote: > The implementation of io.WriteString appears to allocate a new byte slice > and copy the string into it: > > w.Write([]byte(s)) > > Only if the writer does not implement `io.StringWriter`. Avoiding this allocation where possible is exactly why `

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Henry
Are we talking about testing the domain logic or the data persistence? . If it is about testing data persistence, rephrasing my earlier response, we do not test data persistence, not very thoroughly anyway, because it is auto-generated by a tool. We did however thoroughly tested the tool (and t

[go-nuts] unsafe string to []byte

2021-07-27 Thread Steve Roth
The implementation of io.WriteString appears to allocate a new byte slice and copy the string into it: w.Write([]byte(s)) Many third party libraries avoid the allocation and copy with techniques like: var b []byte sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) bh := (*reflect.SliceHeader)(uns

[go-nuts] Does the time cost of the mark phase in gc is mainly depending on the amount of the living objects and has very little to do with the amount of unused objects?

2021-07-27 Thread rmfr
Hi, I'm reading the GC implementation of Golang, and some questions have come to me. As the title described: Proposition 1: The time cost of the mark phase in GC is mainly depending on the amount of the living objects. Proposition 2: The time cost of the mark phase in GC has very little

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Levieux Michel
I'm not quite sure the intent is the same? Generating models only reduces the cognitive and time overhead of going back and forth from the code to the db. It does not test anything. Having a model that you are sure is a reflection of the db does not help you know that the logic going with it works?

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Henry
We go-generate the mapping between the data models and the database. It was tedious to write such tool, but it was a time well spent. Now we just work with data models and not worry about testing the SQL instructions. Occasionally, we use SQLite in-memory database to double-check certain functi

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Markus Zimmermann
We switched from SQLite to PostgreSQL as our "in memory" database. We use an SQL database so we do not have to mock DB calls and maintain an interface. If that is something that is interesting i could trigger a blog post about what we did and why? On Tuesday, July 27, 2021 at 10:21:23 AM UTC+2

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Levieux Michel
Hi, IMO, specific mocks like DATA-DOG's tend to be complicated to use and have behaviors that should not appear in a mock, which would ideally tend to have no logic at all. There are several mock packages that you can find here [and BTW if you have t

[go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Amit Saha
Hi all, I am just looking at options to write tests for parts of my application that interacts with a SQL database. So far it seems like the community has few distinct schools of thought: - Mocks (For e.g. using https://pkg.go.dev/github.com/DATA-DOG/go-sqlmock) - In-memory "real" DB solutions