Skip to content

Instantly share code, notes, and snippets.

@lootek
Created May 2, 2023 08:24
Show Gist options
  • Save lootek/bba5d385b3ec6f6c52d17880d17b07bb to your computer and use it in GitHub Desktop.
Save lootek/bba5d385b3ec6f6c52d17880d17b07bb to your computer and use it in GitHub Desktop.
// go test -bench=. sortalloc_test.go
package main
import (
"sort"
"testing"
)
func BenchmarkSortStrings(b *testing.B) {
s := []string{"heart", "lungs", "brain", "kidneys", "pancreas"}
b.ReportAllocs()
for i := 0; i < b.N; i++ {
sort.Strings(s)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment