Skip to content

Instantly share code, notes, and snippets.

@Luigi-Pizzolito
Created February 12, 2024 23:53
Show Gist options
  • Save Luigi-Pizzolito/385759cd87b70ac0fbf61cf6e4c81b37 to your computer and use it in GitHub Desktop.
Save Luigi-Pizzolito/385759cd87b70ac0fbf61cf6e4c81b37 to your computer and use it in GitHub Desktop.
Monitor channel buffer size continously to determine optimum capacity.
//! channel capacity monitoring for profiling
func monitorChan[T any](ch chan T, name string) {
chanMonitorInterval := time.Second
for {
// if len(ch) == cap(ch) {
fmt.Printf("Channel: %s, Size: %d\n", name, len(ch))
// }
time.Sleep(chanMonitorInterval)
}
}
//! Call this after creating channel
go monitorChan(procFrameQueue1, "channel_from->channel_to")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment