1
0
mirror of https://github.com/DataDog/go-profiler-notes.git synced 2025-07-15 23:54:16 +02:00
Files
go-profiler-notes/examples/pseudo-code/pseudo-block.txt
Felix Geisendörfer 350a4ab46c pseudo code
2021-05-24 11:51:13 +02:00

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