Merge pull request 'Add logging for performance analysis' (#1) from logg into main
Reviewed-on: https://git.thegrind.dev/thegrind/papibot/pulls/1
This commit is contained in:
commit
dd65e50731
20
main.go
20
main.go
@ -140,10 +140,15 @@ func playOnVoiceChannel(voiceChannel *dg.VoiceConnection) {
|
|||||||
|
|
||||||
packets := [][]byte{}
|
packets := [][]byte{}
|
||||||
|
|
||||||
|
startTime := time.Now()
|
||||||
|
|
||||||
|
bytes_sent := 0
|
||||||
for {
|
for {
|
||||||
// I read in the RFC that frames will not be bigger than this size
|
// I read in the RFC that frames will not be bigger than this size
|
||||||
p := make([]byte, 960)
|
p := make([]byte, 960)
|
||||||
n, err := ffmpegOut.Read(p)
|
n, err := ffmpegOut.Read(p)
|
||||||
|
bytes_sent = bytes_sent + n
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Bytes: %d", n)
|
log.Printf("Bytes: %d", n)
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
@ -157,14 +162,29 @@ func playOnVoiceChannel(voiceChannel *dg.VoiceConnection) {
|
|||||||
packets = append(packets, p[:n])
|
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)
|
voiceChannel.Speaking(true)
|
||||||
time.Sleep(time.Second * 2)
|
time.Sleep(time.Second * 2)
|
||||||
log.Println("Playing sound")
|
log.Println("Playing sound")
|
||||||
|
|
||||||
|
startTime = time.Now()
|
||||||
|
bytes_sent = 0
|
||||||
for _, p := range packets {
|
for _, p := range packets {
|
||||||
log.Printf("Sending packet: %d bytes", len(p))
|
log.Printf("Sending packet: %d bytes", len(p))
|
||||||
|
bytes_sent += len(p)
|
||||||
|
// packets_sent := packets_sent + p
|
||||||
voiceChannel.OpusSend <- 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")
|
log.Println("Ended stream")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user