diff --git a/engine/storage_redis_test.go b/engine/storage_redis_test.go index 2625f6e42..fd58f566f 100644 --- a/engine/storage_redis_test.go +++ b/engine/storage_redis_test.go @@ -27,68 +27,10 @@ import ( "github.com/cgrates/cgrates/utils" ) -// var rs *RedisStorage - -// func init() { -// rs, _ = NewRedisStorage("localhost", 10, "cgrates", "", "json", 10, 20, -// "", false, 5*time.Second, 0, 0, 0, 0, false, "", "", "") -// } - -// func storeInDB() { -// chargerProfile := &ChargerProfile{ -// ID: "TestA_CHARGER1", -// Tenant: "cgrates.org", -// FilterIDs: []string{"*string:~*req.TestCase:AdminSAPIs"}, -// Weights: utils.DynamicWeights{ -// { -// Weight: 30, -// }, -// }, -// Blockers: utils.DynamicBlockers{ -// { -// Blocker: false, -// }, -// }, -// RunID: "run1", -// AttributeIDs: []string{"ATTR_TEST1"}, -// } -// id := "ChargerP" -// var prfID string -// for i := 0; i <= 10000; i++ { -// if i%1000 == 0 { -// if (i/1000)%2 == 0 { -// prfID = "TestA:" + strconv.Itoa(i) + ":" + id -// } else { -// prfID = "TestB:" + strconv.Itoa(i) + ":" + id -// } -// } -// chargerProfile.ID = prfID -// rs.SetChargerProfileDrv(context.Background(), chargerProfile) -// } -// } - -// func BenchmarkRedisScan(b *testing.B) { -// storeInDB() -// for i := 0; i < b.N; i++ { -// rs.GetKeysForPrefix(context.Background(), "TestA") -// } -// prfx := []string{"TestA", "TestB", "Test"} -// for _, v := range prfx { -// b.Run(fmt.Sprintf("test case: prefix = %q", prfx), func(b *testing.B) { -// for i := 0; i < b.N; i++ { -// rs.GetKeysForPrefix(context.Background(), v) -// } -// }) -// } -// rs.Flush("") - -// } - -func BenchmarkRedisScan(b *testing.B) { - rs, err := NewRedisStorage("127.0.0.1:6379", 10, "cgrates", "", "json", 10, 20, +// go test -bench RedisGetKeysForPrefix -run=^# -count 3 -benchtime=10s +func BenchmarkRedisGetKeysForPrefix(b *testing.B) { + rs, _ := NewRedisStorage("127.0.0.1:6379", 10, "cgrates", "", "json", 10, 20, "", false, 5*time.Second, 0, 0, 0, 0, false, "", "", "") - fmt.Println(err) - fmt.Println(rs) chargerProfile := &ChargerProfile{ ID: "TestA_CHARGER1", Tenant: "cgrates.org", @@ -108,9 +50,9 @@ func BenchmarkRedisScan(b *testing.B) { } id := "ChargerP" var prfID string - for i := 0; i <= 20; i++ { - if i%10 == 0 { - if (i/10)%2 == 0 { + for i := 0; i <= 10000; i++ { + if i%1000 == 0 { + if (i/1000)%2 == 0 { prfID = "TestA:" } else { prfID = "TestB:"