mirror of
https://github.com/jech/galene.git
synced 2024-12-22 07:15:47 +01:00
Fix rounding in estimator.
The test was buggy.
This commit is contained in:
parent
474c58cc7d
commit
b5f8ea0e23
2 changed files with 4 additions and 4 deletions
|
@ -40,9 +40,8 @@ func (e *Estimator) swap(now uint64) {
|
|||
|
||||
var rate, packetRate uint32
|
||||
if jiffies >= rtptime.JiffiesPerSec/1000 {
|
||||
rate = uint32(uint64(bytes) * rtptime.JiffiesPerSec / jiffies)
|
||||
packetRate =
|
||||
uint32(uint64(packets) * rtptime.JiffiesPerSec / jiffies)
|
||||
rate = uint32((uint64(bytes)*rtptime.JiffiesPerSec + jiffies/2) / jiffies)
|
||||
packetRate = uint32((uint64(packets)*rtptime.JiffiesPerSec + jiffies/2) / jiffies)
|
||||
}
|
||||
atomic.StoreUint32(&e.rate, rate)
|
||||
atomic.StoreUint32(&e.packetRate, packetRate)
|
||||
|
|
|
@ -2,13 +2,14 @@ package estimator
|
|||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/jech/galene/rtptime"
|
||||
)
|
||||
|
||||
func TestEstimator(t *testing.T) {
|
||||
now := rtptime.Jiffies()
|
||||
e := New(rtptime.JiffiesPerSec)
|
||||
e := New(time.Second)
|
||||
|
||||
e.estimate(now)
|
||||
e.Accumulate(42)
|
||||
|
|
Loading…
Reference in a new issue