Discover Packages
github.com/chenquan/xbytes
package
module
Version:
v0.1.0
Opens a new window with list of versions in this module.
Published: Nov 27, 2021
License: Apache-2.0
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
Xbytes
Install
go get -u github.com/chenquan/xbytes
Use
package main
import (
"github.com/chenquan/xbytes"
)
func main() {
pool := xbytes.GetNBytesPool(10)
// Get
b := pool.Get()
_ = b
// Recover
pool.Put(b)
}
Benchmark
goos: windows
goarch: amd64
pkg: github.com/chenquan/xbytes
cpu: Intel(R) Core(TM) i5-8265UC CPU @ 1.60GHz
BenchmarkMakeBytes-8 2281 591449 ns/op 2264156 B/op 28 allocs/op
BenchmarkGetNBytesPool-8 10000 127145 ns/op 4811 B/op 149 allocs/op
Expand ▾
Collapse ▴
Documentation
¶
Pool Represents a pool of the same byte size.
func GetNBytesPool(nBytes int ) *Pool
GetNBytesPool returns a bytes sync.Pool.
It is recommended to use n Byte greater than or equal to 64.
Get Returns a bytes of slice.
Put Recovers a byte slice.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.