demote NewStream
This commit is contained in:
parent
ecace73aed
commit
ae82433a8f
@ -1,4 +1,4 @@
|
|||||||
package main
|
package bandwidth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
"container/list"
|
||||||
@ -29,7 +29,7 @@ type stream struct {
|
|||||||
max time.Duration
|
max time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStream(seconds []int) *stream {
|
func newStream(seconds []int) *stream {
|
||||||
extents := []time.Duration{}
|
extents := []time.Duration{}
|
||||||
for _, s := range seconds {
|
for _, s := range seconds {
|
||||||
extents = append(extents, time.Duration(-s)*time.Second)
|
extents = append(extents, time.Duration(-s)*time.Second)
|
||||||
@ -113,8 +113,8 @@ func NewBandwidth(seconds []int, dt time.Duration) (*Bandwidth, error) {
|
|||||||
Tx: make(chan []float64),
|
Tx: make(chan []float64),
|
||||||
dt: dt,
|
dt: dt,
|
||||||
Quit: make(chan interface{}),
|
Quit: make(chan interface{}),
|
||||||
rxstream: NewStream(seconds),
|
rxstream: newStream(seconds),
|
||||||
txstream: NewStream(seconds),
|
txstream: newStream(seconds),
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package main
|
package bandwidth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
@ -55,7 +55,7 @@ func TestOncePerSecond(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
bw.rxstream = NewStream([]int{1, 10, 60})
|
bw.rxstream = newStream([]int{1, 10, 60})
|
||||||
var i int64 = 0
|
var i int64 = 0
|
||||||
for ; i < 1000; i++ {
|
for ; i < 1000; i++ {
|
||||||
d := datum{
|
d := datum{
|
||||||
@ -72,7 +72,7 @@ func TestOneOverManySeconds(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
bw.rxstream = NewStream([]int{1, 10, 60})
|
bw.rxstream = newStream([]int{1, 10, 60})
|
||||||
var i int64 = 0
|
var i int64 = 0
|
||||||
for ; i < 1000; i++ {
|
for ; i < 1000; i++ {
|
||||||
d := datum{
|
d := datum{
|
||||||
@ -89,7 +89,7 @@ func TestManyPerSecond(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
bw.rxstream = NewStream([]int{1, 10, 60})
|
bw.rxstream = newStream([]int{1, 10, 60})
|
||||||
var i int64 = 0
|
var i int64 = 0
|
||||||
for ; i < 10000; i++ {
|
for ; i < 10000; i++ {
|
||||||
d := datum{
|
d := datum{
|
||||||
@ -106,7 +106,7 @@ func TestEmpty(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
bw.rxstream = NewStream([]int{1, 10, 60})
|
bw.rxstream = newStream([]int{1, 10, 60})
|
||||||
validate(t, bw.rxstream.averages(), []float64{})
|
validate(t, bw.rxstream.averages(), []float64{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user