Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
realityone committed Jun 16, 2023
1 parent b6b67d6 commit abb1a36
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion circuitbreaker/sre/sre_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func getSREBreaker() *Breaker {
stat := window.NewRollingCounter(counterOpts)
return &Breaker{
stat: stat,
r: rand.New(rand.NewSource(time.Now().UnixNano())),
r: rand.New(rand.NewSource(uint64(time.Now().UnixNano()))),

request: 100,
k: 2,
Expand Down
10 changes: 5 additions & 5 deletions hotkey/hotkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func benchmarkHotkey(b *testing.B, autoCache bool, writePercent float64, whileli
if err != nil {
b.Fatalf("new hot key failed,err:=%v", err)
}
random := rand.New(rand.NewSource(time.Now().Unix()))
zipf := rand.NewZipf(rand.New(rand.NewSource(time.Now().Unix())), 2, 2, 1000)
random := rand.New(rand.NewSource(uint64(time.Now().Unix())))
zipf := rand.NewZipf(rand.New(rand.NewSource(uint64(time.Now().Unix()))), 2, 2, 1000)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestHotkeyBlacklist(t *testing.T) {
if err != nil {
t.Fatalf("new hot key failed,err:=%v", err)
}
zipf := rand.NewZipf(rand.New(rand.NewSource(time.Now().Unix())), 2, 2, 1000)
zipf := rand.NewZipf(rand.New(rand.NewSource(uint64(time.Now().Unix()))), 2, 2, 1000)
for i := 0; i < 100000; i++ {
key := strconv.FormatInt(int64(zipf.Uint64()), 10)
h.AddWithValue(key, key, 1)
Expand Down Expand Up @@ -214,8 +214,8 @@ func testHotkeyHit(t *testing.T) {
if err != nil {
t.Fatalf("new hot key failed,err:=%v", err)
}
random := rand.New(rand.NewSource(time.Now().Unix()))
zipf := rand.NewZipf(rand.New(rand.NewSource(time.Now().Unix())), 1.1, 2, 10000000)
random := rand.New(rand.NewSource(uint64(time.Now().Unix())))
zipf := rand.NewZipf(rand.New(rand.NewSource(uint64(time.Now().Unix()))), 1.1, 2, 10000000)
var total int
var hit int
for {
Expand Down
4 changes: 2 additions & 2 deletions topk/heavykeeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestTopkList(t *testing.T) {
// zipfan distribution
zipf := rand.NewZipf(rand.New(rand.NewSource(time.Now().Unix())), 3, 2, 1000)
zipf := rand.NewZipf(rand.New(rand.NewSource(uint64(time.Now().Unix()))), 3, 2, 1000)
topk := NewHeavyKeeper(10, 10000, 5, 0.925, 0)
dataMap := make(map[string]int)
for i := 0; i < 10000; i++ {
Expand All @@ -33,7 +33,7 @@ func TestTopkList(t *testing.T) {
}

func BenchmarkAdd(b *testing.B) {
zipf := rand.NewZipf(rand.New(rand.NewSource(time.Now().Unix())), 2, 2, 1000)
zipf := rand.NewZipf(rand.New(rand.NewSource(uint64(time.Now().Unix()))), 2, 2, 1000)
var data []string = make([]string, 1000)
for i := 0; i < 1000; i++ {
data[i] = strconv.FormatUint(zipf.Uint64(), 10)
Expand Down

0 comments on commit abb1a36

Please sign in to comment.