Add logging for performance analysis #1
20
main.go
20
main.go
@ -140,10 +140,15 @@ func playOnVoiceChannel(voiceChannel *dg.VoiceConnection) {
|
||||
|
||||
packets := [][]byte{}
|
||||
|
||||
startTime := time.Now()
|
||||
|
||||
bytes_sent := 0
|
||||
for {
|
||||
// I read in the RFC that frames will not be bigger than this size
|
||||
p := make([]byte, 960)
|
||||
n, err := ffmpegOut.Read(p)
|
||||
bytes_sent = bytes_sent + n
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Bytes: %d", n)
|
||||
if err == io.EOF {
|
||||
@ -157,14 +162,29 @@ func playOnVoiceChannel(voiceChannel *dg.VoiceConnection) {
|
||||
packets = append(packets, p[:n])
|
||||
}
|
||||
|
||||
elapsedTime := time.Since(startTime)
|
||||
|
||||
log.Printf("bytes sent = %d", bytes_sent)
|
||||
log.Printf("Took %s seconds to run", elapsedTime)
|
||||
// log.Printf("Bytes/Sec = %s", elapsedTime)
|
||||
|
||||
voiceChannel.Speaking(true)
|
||||
time.Sleep(time.Second * 2)
|
||||
log.Println("Playing sound")
|
||||
|
||||
startTime = time.Now()
|
||||
bytes_sent = 0
|
||||
for _, p := range packets {
|
||||
log.Printf("Sending packet: %d bytes", len(p))
|
||||
bytes_sent += len(p)
|
||||
// packets_sent := packets_sent + p
|
||||
voiceChannel.OpusSend <- p
|
||||
}
|
||||
|
||||
elapsedTime = time.Since(startTime)
|
||||
log.Printf("Packets = %d", len(packets))
|
||||
log.Printf("Network bytes sent = %d", bytes_sent)
|
||||
log.Printf("Took %s seconds to run", elapsedTime)
|
||||
log.Println("Ended stream")
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user