You've already forked go-profiler-notes
mirror of
https://github.com/DataDog/go-profiler-notes.git
synced 2025-07-15 23:54:16 +02:00
18 lines
413 B
Plaintext
18 lines
413 B
Plaintext
func chansend(channel, msg):
|
|
// non-blocking send
|
|
if ready(channel):
|
|
send(channel, msg)
|
|
return
|
|
|
|
t0 = now()
|
|
// let scheduler run another goroutine
|
|
// until the channel is ready
|
|
wait_ready(channel)
|
|
duration = now() - t0
|
|
send(channel, msg)
|
|
// sample a fraction of blocking events
|
|
if random_sample(duration):
|
|
s = stacktrace()
|
|
profile[s].count++
|
|
profile[s].duration += duration
|