Compare commits
2 Commits
b0b8ac2d5b
...
5d5af6e926
Author | SHA1 | Date | |
---|---|---|---|
5d5af6e926 | |||
714462c36f |
11
.drone.yml
11
.drone.yml
@ -3,9 +3,18 @@ kind: pipeline
|
|||||||
name: default
|
name: default
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: gosec security analysis
|
||||||
|
image: securego/gosec
|
||||||
|
commands:
|
||||||
|
- gosec ./...
|
||||||
|
- name: staticcheck analysis
|
||||||
|
image: golang
|
||||||
|
commands:
|
||||||
|
- go install honnef.co/go/tools/cmd/staticcheck
|
||||||
|
- "$(go env GOPATH)/bin/staticcheck"
|
||||||
- name: build, test and benchmark
|
- name: build, test and benchmark
|
||||||
image: golang
|
image: golang
|
||||||
commands:
|
commands:
|
||||||
|
- go build -race
|
||||||
- go test
|
- go test
|
||||||
- go test -bench=.
|
- go test -bench=.
|
||||||
- go build
|
|
||||||
|
1
go.sum
1
go.sum
@ -1,3 +1,4 @@
|
|||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/eapache/queue.v1 v1.1.0 h1:EldqoJEGtXYiVCMRo2C9mePO2UUGnYn2+qLmlQSqPdc=
|
gopkg.in/eapache/queue.v1 v1.1.0 h1:EldqoJEGtXYiVCMRo2C9mePO2UUGnYn2+qLmlQSqPdc=
|
||||||
gopkg.in/eapache/queue.v1 v1.1.0/go.mod h1:wNtmx1/O7kZSR9zNT1TTOJ7GLpm3Vn7srzlfylFbQwU=
|
gopkg.in/eapache/queue.v1 v1.1.0/go.mod h1:wNtmx1/O7kZSR9zNT1TTOJ7GLpm3Vn7srzlfylFbQwU=
|
||||||
|
@ -4,16 +4,13 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var testQ = NewQueue()
|
var testQ = NewQueue()
|
||||||
|
|
||||||
func testAdd(n int) {
|
func testAdd(n int) {
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
testQ.Add(func() {
|
testQ.Add(func() {})
|
||||||
time.Sleep(1)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,10 +33,7 @@ func SimpleScheduler(tq *TaskQueue) bool {
|
|||||||
queued++
|
queued++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if queued > 0 {
|
return (queued > 0)
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TimeSliceScheduler attempts to give tasks a fair share of the Stats()
|
// TimeSliceScheduler attempts to give tasks a fair share of the Stats()
|
||||||
|
2
stats.go
2
stats.go
@ -74,7 +74,7 @@ func (s *Stat) Start() (start time.Time) {
|
|||||||
// This will fluctuate between 90-100% of the window size set when the state
|
// This will fluctuate between 90-100% of the window size set when the state
|
||||||
// was created, as internal buckets roll over.
|
// was created, as internal buckets roll over.
|
||||||
func (s *Stat) Duration() time.Duration {
|
func (s *Stat) Duration() time.Duration {
|
||||||
return time.Now().Sub(s.Start())
|
return time.Since(s.Start())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rate returns the flow rate of this counter, which is the current rolling
|
// Rate returns the flow rate of this counter, which is the current rolling
|
||||||
|
@ -11,10 +11,7 @@ func (list UIntSlice) Len() int {
|
|||||||
|
|
||||||
// Less helps fulfill sort.Interface.
|
// Less helps fulfill sort.Interface.
|
||||||
func (list UIntSlice) Less(i, j int) bool {
|
func (list UIntSlice) Less(i, j int) bool {
|
||||||
if list[i] <= list[j] {
|
return list[i] <= list[j]
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swap helps fulfill sort.Interface
|
// Swap helps fulfill sort.Interface
|
||||||
|
Loading…
Reference in New Issue
Block a user