mirror of
https://github.com/stryan/mumble-discord-bridge.git
synced 2024-12-27 00:55:39 -05:00
idlejitter test
This commit is contained in:
parent
cc387ba3b9
commit
d18691d0f0
2
Makefile
2
Makefile
@ -16,7 +16,7 @@ test-chart: SHELL:=/bin/bash
|
||||
test-chart:
|
||||
go test &
|
||||
until pidof mumble-discord-bridge.test; do continue; done;
|
||||
psrecord --plot test-cpu-memory.png $$(pidof mumble-discord-bridge.test)
|
||||
psrecord --plot docs/test-cpu-memory.png $$(pidof mumble-discord-bridge.test)
|
||||
|
||||
docker-latest:
|
||||
docker build -t stieneee/mumble-discord-bridge:latest .
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 27 KiB |
Binary file not shown.
Before Width: | Height: | Size: 32 KiB |
@ -2,7 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@ -100,3 +102,40 @@ func TestSleepCT(t *testing.T) {
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func TestIdleJitter(t *testing.T) {
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
const testSize = 100000
|
||||
const sleepTarget = time.Millisecond
|
||||
|
||||
res := make([]time.Duration, testSize)
|
||||
|
||||
for i := 0; i < testSize; i++ {
|
||||
start := time.Now()
|
||||
target := start.Add(sleepTarget)
|
||||
|
||||
time.Sleep(sleepTarget)
|
||||
|
||||
res[i] = time.Since(target)
|
||||
}
|
||||
|
||||
sort.Slice(res, func(i, j int) bool {
|
||||
return res[i] < res[j]
|
||||
})
|
||||
|
||||
var total float64 = 0
|
||||
for i := 0; i < testSize; i++ {
|
||||
total += float64(res[i])
|
||||
}
|
||||
avg := time.Duration(total / testSize)
|
||||
|
||||
nineFive := int64(math.Round(testSize * 0.95))
|
||||
nineNine := int64(math.Round(testSize * 0.99))
|
||||
nineNineNine := int64(math.Round(testSize * 0.999))
|
||||
|
||||
fmt.Println("IdleJitter test", testSize, sleepTarget)
|
||||
fmt.Println("IdleJitter results min/avg/95/99/99.9/max", res[0], avg, res[nineFive], res[nineNine], res[nineNineNine], res[testSize-1])
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user