News for hackers. Stuff that matters.
Re:Faster Sorting with Go Generics by eliben on Saturday April 02, 2022 @05:20PM (#30891782)
The change mentioned at the top of the post (https://go-review.googlesource.com/c/exp/+/378134) also has a benchmark to compare sorting structs using sort.Slice vs a new generic approach that uses a comparison function:

    name           old time/op  new time/op  delta
    SortStructs-8  18.6ms ± 2%  15.9ms ± 3%  -14.43%  (p=0.000 n=10+10)
14.4% is the speedup of the generic version.

The article explains why this happens (towards the end).

Re:Faster Sorting with Go Generics by tedunangst on Saturday April 02, 2022 @07:25PM (#30892590)
Unsolicited commentary: I think my commitment to a thorough reading was limited by my interest in the performance of bubble sort. On the other hand, the code for sort.Search also fits in a blog post, and it's a function I have called inside a loop.
Re:Faster Sorting with Go Generics by eliben on Saturday April 02, 2022 @11:53PM (#30894278)
That's a good point, thank you for bringing it up. Finding the right examples is really tricky. sort.Search is binary search and hence a bit tricky to benchmark properly because of how ridiculously fast it is. Only a handful of comparison calls are made even for huge slices.