Comments (3)
testing in linux
/home/go/src/github.com/tsingson/timingwheel # go version
go version go1.12.9 linux/amd64
/home/go/src/github.com/tsingson/timingwheel #
/home/go/src/github.com/tsingson/timingwheel # go test -race -count=1 .
FAIL
FAIL github.com/RussellLuo/timingwheel 3.606s
/home/go/src/github.com/tsingson/timingwheel # go test -race -v -count=1 .
=== RUN TestTimingWheel_AfterFunc
=== RUN TestTimingWheel_AfterFunc/#00
=== RUN TestTimingWheel_AfterFunc/#01
=== RUN TestTimingWheel_AfterFunc/#02
=== RUN TestTimingWheel_AfterFunc/#03
=== RUN TestTimingWheel_AfterFunc/#04
=== RUN TestTimingWheel_AfterFunc/#05
=== RUN TestTimingWheel_AfterFunc/#06
--- FAIL: TestTimingWheel_AfterFunc (1.73s)
--- FAIL: TestTimingWheel_AfterFunc/#00 (0.01s)
timingwheel_test.go:38: NewTimer(1ms) want [2019-08-19 02:30:04.941 +0000 UTC, 2019-08-19 02:30:04.946 +0000 UTC], got 2019-08-19 02:30:04.95 +0000 UTC
testing.go:809: race detected during execution of test
--- PASS: TestTimingWheel_AfterFunc/#01 (0.01s)
--- PASS: TestTimingWheel_AfterFunc/#02 (0.01s)
--- PASS: TestTimingWheel_AfterFunc/#03 (0.05s)
--- PASS: TestTimingWheel_AfterFunc/#04 (0.10s)
--- PASS: TestTimingWheel_AfterFunc/#05 (0.50s)
--- PASS: TestTimingWheel_AfterFunc/#06 (1.04s)
testing.go:809: race detected during execution of test
=== RUN Example_startTimer
--- PASS: Example_startTimer (1.00s)
=== RUN Example_stopTimer
--- PASS: Example_stopTimer (0.90s)
FAIL
FAIL github.com/RussellLuo/timingwheel 3.652s
/home/go/src/github.com/tsingson/timingwheel #
from timingwheel.
change testing code to
package timingwheel_test
import (
"testing"
"time"
"github.com/RussellLuo/timingwheel"
)
func TestTimingWheel_AfterFunc(t *testing.T) {
tw := timingwheel.NewTimingWheel(time.Millisecond, 20)
tw.Start()
defer tw.Stop()
durations := []time.Duration{
//1 * time.Millisecond,
5 * time.Millisecond,
10 * time.Millisecond,
50 * time.Millisecond,
100 * time.Millisecond,
500 * time.Millisecond,
1 * time.Second,
}
for _, d := range durations {
t.Run("", func(t *testing.T) {
exitC := make(chan time.Time)
start := time.Now()
tw.AfterFunc(d, func() {
exitC <- time.Now()
})
got := (<-exitC).Truncate(time.Millisecond)
min := start.Add(d).Truncate(time.Millisecond)
err := 5 * time.Millisecond
if got.Before(min) || got.After(min.Add(err)) {
t.Errorf("NewTimer(%s) want [%s, %s], got %s", d, min, min.Add(err), got)
}
})
}
}
result is OK:
/home/go/src/github.com/tsingson/timingwheel # go test -race -v -count=1 .
=== RUN TestTimingWheel_AfterFunc
=== RUN TestTimingWheel_AfterFunc/#00
=== RUN TestTimingWheel_AfterFunc/#01
=== RUN TestTimingWheel_AfterFunc/#02
=== RUN TestTimingWheel_AfterFunc/#03
=== RUN TestTimingWheel_AfterFunc/#04
=== RUN TestTimingWheel_AfterFunc/#05
--- PASS: TestTimingWheel_AfterFunc (1.68s)
--- PASS: TestTimingWheel_AfterFunc/#00 (0.01s)
--- PASS: TestTimingWheel_AfterFunc/#01 (0.01s)
--- PASS: TestTimingWheel_AfterFunc/#02 (0.05s)
--- PASS: TestTimingWheel_AfterFunc/#03 (0.10s)
--- PASS: TestTimingWheel_AfterFunc/#04 (0.50s)
--- PASS: TestTimingWheel_AfterFunc/#05 (1.00s)
=== RUN Example_startTimer
--- PASS: Example_startTimer (1.00s)
=== RUN Example_stopTimer
--- PASS: Example_stopTimer (0.90s)
FAIL
FAIL github.com/RussellLuo/timingwheel 3.605s
/home/go/src/github.com/tsingson/timingwheel #
that meaning , delay must more than 1ms ????
try
@ -13,7 +13,7 @@ func TestTimingWheel_AfterFunc(t *testing.T) {
defer tw.Stop()
durations := []time.Duration{
// 1 * time.Millisecond,
2 * time.Millisecond,
5 * time.Millisecond,
10 * time.Millisecond,
50 * time.Millisecond,
it's PASS all testing and no data race.
from timingwheel.
@tsingson Sorry for the delayed reply.
From your reporting, obviously, this is an issue of data race. I'll fix it soon.
from timingwheel.
Related Issues (20)
- 大佬,分层管理定时器在哪里实现的呢? 每个定时器都是一个协程处理哦? HOT 2
- 全局是否只创建一个时间轮,还是需要考虑分时间等级进行创建呢 HOT 2
- deadlock HOT 1
- Scheduler 例子的问题 HOT 1
- DelayQueue poll退出时需要清理wakeupC,不然offer会卡住吧 HOT 11
- bucket flush的时候,为什么可能存在需要restart的timer呢? HOT 1
- TimingWheel中currentTime和overflowWheel变量存在竞争问题 HOT 3
- TODO: Improve the coordination with b.Add()
- 通过timingwheel写了一个定时任务的模块,出现有的任务不执行,请问如何排查呢 HOT 1
- 时间轮是不是在go的版本1.14之后与timer对比就没有优势了?
- 任务可以持久化吗?如果程序重启,未执行的任务可以继续执行吗 HOT 1
- 缺少 LICENSE 文件
- 请教一下, 为什么是用链表? HOT 2
- bucket Flush 中链表的删除操作导致多个相同的定时器只会被执行一个 HOT 1
- 关于addOrRun方法的疑问
- 大佬啥时候有空,修修bug
- timewheel启动了很久,新插入一个定时器直接就过期 HOT 1
- 为什么用这个b unsafe.Pointer 而不用这个*bucket
- 计算tw.buckets索引的问题 HOT 1
- Memory leaking issue after stop
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from timingwheel.