Skip to content

Commit

Permalink
update benchmark data
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangdongdong2 committed Apr 14, 2021
1 parent 14bdac2 commit 535dfe6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ func main() {

```sh
go test -count=1 -benchtime 5s -benchmem . -bench .
0.9948495475
0.9948804265
goos: darwin
goarch: amd64
pkg: github.com/flyaways/timer
cpu: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
BenchmarkFlyawaysTimer-4 239080164 25.83 ns/op 0 B/op 0 allocs/op
BenchmarkTarsGoTimer-4 144200496 43.22 ns/op 0 B/op 0 allocs/op
BenchmarkOfficalTimer-4 9556473 671.0 ns/op 206 B/op 3 allocs/op
BenchmarkRussellLuoTimer-4 15525009 463.3 ns/op 167 B/op 2 allocs/op
BenchmarkFlyawaysTimer-4 174450506 53.58 ns/op 0 B/op 0 allocs/op
BenchmarkTarsGoTimer-4 79953462 74.30 ns/op 0 B/op 0 allocs/op
BenchmarkOfficalTimer-4 12491235 519.6 ns/op 201 B/op 3 allocs/op
BenchmarkRussellLuoTimer-4 13017769 514.1 ns/op 164 B/op 2 allocs/op
PASS
ok github.com/flyaways/timer 44.648s
ok github.com/flyaways/timer 43.342s
```
32 changes: 20 additions & 12 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,29 @@ import (
//BenchmarkTimeWheel benchmarks timewheel.
func BenchmarkFlyawaysTimer(b *testing.B) {
t := New(20, time.Millisecond*5)
for i := 0; i < b.N; i++ {
t.After(time.Millisecond * 100)
}
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
t.After(time.Millisecond * 100)
}
})
}

//BenchmarkTimeWheel benchmarks timewheel.
func BenchmarkTarsGoTimer(b *testing.B) {
for i := 0; i < b.N; i++ {
rtimer.After(time.Millisecond * 100)
}
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
rtimer.After(time.Millisecond * 100)
}
})
}

//BenchmarkTimeBase benchmark origin timer.
func BenchmarkOfficalTimer(b *testing.B) {
for i := 0; i < b.N; i++ {
time.After(time.Millisecond * 100)
}
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
time.After(time.Millisecond * 100)
}
})
}

//BenchmarkRussellLuoTimer benchmark timewheel.
Expand All @@ -36,7 +42,9 @@ func BenchmarkRussellLuoTimer(b *testing.B) {
tw.Start()
defer tw.Stop()

for i := 0; i < b.N; i++ {
tw.AfterFunc(time.Millisecond*100, func() {})
}
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
tw.AfterFunc(time.Millisecond*100, func() {})
}
})
}

0 comments on commit 535dfe6

Please sign in to comment.