MCPcopy Create free account
hub / github.com/cloudwego/netpoll / BenchmarkStringToSliceByte

Function BenchmarkStringToSliceByte

nocopy_linkbuffer_test.go:874–889  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

872}
873
874func BenchmarkStringToSliceByte(b *testing.B) {
875 b.StopTimer()
876 s := "hello world"
877 var bs []byte
878 if false {
879 b.Logf("bs = %s", bs)
880 }
881
882 // benchmark
883 b.ReportAllocs()
884 b.StartTimer()
885 for i := 0; i < b.N; i++ {
886 bs = unsafe.Slice(unsafe.StringData(s), len(s))
887 }
888 _ = bs
889}
890
891func BenchmarkStringToCopy(b *testing.B) {
892 b.StopTimer()

Callers

nothing calls this directly

Calls 1

SliceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…