https://github.com/tada-team/timerpool
https://github.com/tada-team/timerpool
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tada-team/timerpool
- Owner: tada-team
- License: mit
- Created: 2021-03-07T23:23:20.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-07T23:34:21.000Z (over 4 years ago)
- Last Synced: 2025-01-30T02:14:55.613Z (8 months ago)
- Language: Go
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# timerpool
Usage:
```go
import (
"time"
"github.com/tada-team/timerpool"
)func example() {
dur := time.Second
// without pool
timer := time.NewTimer(dur)
defer timer.Stop()
// with pool
timer := timerpool.Get(dur)
defer timerpool.Release(timer)
}
``````text
BenchmarkTimer/cancelled/newTimer-12 343038 3464 ns/op 846 B/op 5 allocs/op
BenchmarkTimer/cancelled/poolTimer-12 1000000 2669 ns/op 729 B/op 5 allocs/op
BenchmarkTimer/used/newTimer-12 2613874 516.9 ns/op 210 B/op 3 allocs/op
BenchmarkTimer/used/poolTimer-12 2319859 458.1 ns/op 13 B/op 0 allocs/op
```